Hi-Q is a peg solitaire game played on a plus-shaped board with 33 holes, numbered 1 to 33:
1 2 3
4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
31 32 33
At the start of a game, some holes contain pegs and the rest are empty. A move takes a peg, jumps it over an adjacent peg into the empty hole immediately beyond, and removes the jumped-over peg. Jumps are only horizontal or vertical, never diagonal. Formally, three holes must be consecutive along a row or a column: a source hole (holding a peg), a middle hole (holding a peg), and a target hole (empty). After the move, the source and middle holes become empty and the target hole holds a peg. For example, if hole 9 is empty while holes 10 and 11 hold pegs, the peg in 11 can jump over 10 into 9, leaving 10 and 11 empty and 9 filled.
Your program makes moves repeatedly until no move is possible, then reports the sum of the numbers of the holes that still contain pegs.
Whenever more than one move is available, the move is chosen deterministically:
These two rules always identify exactly one move.
The first line contains an integer $N$ ($1 \le N \le 10$), the number of games.
The games are then described in order. Each game is given as the list of hole numbers that start with a peg, distinct integers between 1 and 33, followed by a single 0 that terminates the list. The numbers of one game may span several lines, and the amount of whitespace between them is arbitrary. A game may start with no pegs, in which case its list is just 0.
For each game, in the order given, print one line containing the sum of the numbers of the holes that still contain pegs once no further move is possible.