CRIC - Help The Scorers

no tags 

Cricket is a religion in India. Great men like Sachin Tendulkar are considered equal to gods in India !! But They are not technologically advanced in cricket. Technologies like Hawk Eye, Thermal Imaging are available in many cricket playing nation. But Indians still use a paper to mark the scores and wickets on a match. As India is gifted with many programmers, They decided to solve a problem they face in scoring on paper. 

Usually scoring is done on a paper using the following characters. ('6','4','3','2','1','w','.'). 6, 4, 3, 2, 1 corresponds to the scores got in those deliveries, whereas '.' means no run scored and strike is not rotated.'w' corresponds to a wicket. Umpires give the programmer a paper which is marked like this, 3..1.6w6.. . . . .  and so on which contains a character for each delivery bowled on the match. Now its our job to calculate the scores of the player who got out and also the scores of the batsmen who's on strike as well as non striker. Can you do it?

Input

First line consists of number of testcases 't' followed by 't' strings (1 <= t <= 50). Each line consists of following characters only: {'6','4','3','2','1','w','.'}

length of string <=350

Output

Output the scores of the players in the order in which they got out and also the scores of the striker who is not out with two stars "**" and non striker with "*". Always striker first then non striker.

If there was a wicket on the last ball. Output only the non striker with a single star "*". Dont bother about the extras.

Assume no rotation of strike is allowed at the end of each over.

Example

Input:
2
212..3.6.w
33.3.4ww..

Output:
9
5*
7
0
0**
6*

hide comments
John Snow: 2013-06-28 09:13:09

edit AC

Last edit: 2013-06-28 05:20:06

Added by:Shenbaga Prasanna
Date:2013-06-27
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:ASM32-GCC MAWK BC C-CLANG C NCSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG C99 COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JAVA JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PHP PICO PROLOG PYTHON PYPY PYPY3 R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET
Resource:Own