Limits 1s, 512 MB

After Watching a devastating World Cup of Bangladesh Cricket Team, Mr. Papon Decided to Start being coach of the young cricketers of His neighbor team called- ACM(Algorithmic Cosmos Maestro) by himself.


28 November, there’s a match between his neighborhood team vs Charabagh Tiger team. But unfortunately he wasn’t present in the first half of the match where the opponent team was batted first. For some witchcraft or sorcery of the opponent team, the scoreboard manager Didn’t stop the game even after falling off their 10th Wicket and so the Total Target of the match wasn’t Calculated. As a result his team is in a troublesome position because they can not formulate any strategy or target to win this game. Mr. Papon is tired of losing, but he can’t do anything about it, So he turns to you with a sad face for a helping hand, would you help this man just this once?

There Are KK over given. In each over there are XX balls bowled. Each balling outcome will be represented by this format -

  • Run - [ 0,1, 2, 3, 4, 6 ]

  • B - Bowled Out

  • C - Catch Out

  • R - Run Out

  • W - Wide Ball

  • N - No Ball

Since this is no international Match, this doesn't have any Bye Run(extras) and LBW. Only and Only if there’s a “No Ball” and the next Ball gives a Run Out, it Will be considered a Wicket, Other wickets(Bowled Out, Catch Out) will be ignored.  Also The Game is Over when there’s a fall of 10 Wickets, No run After that will be considered. “No ball” and “Wide Ball” will add one run to the score. If there’s a “No ball” and the next ball is a “Wide Ball” or “No ball”, the effect of “No ball” will still remain.

Input

There will be TT test cases. Each test cases have KK overs. Next KK lines Will have, First index XX which indicates the number of balls have been bowled And after there will be XX balls information.

1T,K,X1001\leq T,K,X\leq 100

Xi[0,1,2,3,4,6,B,C,R,W,N]X_{i}\in [0, 1, 2, 3, 4, 6, B, C, R, W, N]

Output

You have to output the total target of the match.

Sample

InputOutput
1
5
7 0 0 1 W B 6 4
7 C N B 3 0 1 C
8 N R 1 2 3 4 W 6
12 N W W N N R W B 1 2 B B 
8 1 1 1 1 1 N N 0
51

Don’t forget to print newline ‘\n’ and no extra spaces.

Submit

Login to submit.

Statistics

28% Solution Ratio
sagorahmedmunnaEarliest, 5M ago
sourov.cseFastest, 0.0s
sourov.cseLightest, 5.2 MB
sagorahmedmunnaShortest, 965B
Toph uses cookies. By continuing you agree to our Cookie Policy.