Problem A
Dominoes 2
Dominoes are lots of fun. Children like to stand the tiles on their side in long lines. When one domino falls, it knocks down the next one, which knocks down the one after that, all the way down the line. However, sometimes a domino fails to knock the next one down. In that case, we have to knock it down by hand to get the dominoes falling again.
Given a set of dominoes that are knocked down by hand, your task is to determine the total number of dominoes that fall.
Input
The first line of input contains one integer specifying the
number of test cases to follow. Each test case begins with a
line containing three integers
Each of the
Output
For each test case, output a line containing one integer, the total number of dominoes that fall over.
Sample Input 1 | Sample Output 1 |
---|---|
1 3 2 1 1 2 2 3 2 |
2 |