
ZOJ Problem Set  3459
The 24PointGame is such a famous game that almost everyone know its name. The rule of the 24PointGame is simple: given 4 poker cards, the player should use the Four Arithmetic Operations("+", "", "*" and "/") to make the numbers of the four cards to 24. For example, given four cards whose numbers are 1, 2, 3 and 9, you can give an answer 2*1*(9+3)=24 or another solution 3*912=24. One day, two famous roles in the popular card game called SanGuoSha, Sima Yi and Zhang Jiao, would like to play the 24PointGame. To judge who is smarter, they add some rules to the game. In the beginning of the game, there are 4 cards in the public place, also, Sima Yi and Zhang Jiao hold some cards respectively. Then, they process the game in turn. In Sima Yi's turn, he can use one of his card to replace a card in the public place, and then he loses the card he uses. In Zhang Jiao's turn, he can use one of his black colored card to exchange with one of the cards in the public place. That's, Zhang Jiao can use a black colored card to change a card in the public place, and gets the card changed. Sima Yi will take the first turn. The two players can choose to change or not to change the public cards in their own turn, and if he doesn't change the public cards, the game is terminated immediately, except for the first turn.(That's to say, in the beginning, if Sima Yi doesn't change a public card, the game continues, and turns to Zhang Jiao's turn.) At last, if Sima Yi can calculate 24 based on the cards in the public place, he wins, otherwise Zhang Jiao wins. Assume that the two men are clever enough, your task is to find the winner of the game. InputThere are multiple test cases. The first line of input is an integer T(1 ≤ T ≤ 23), indicating the number of test cases. Then T cases follow. The first line of each cases is n_{1}, c_{1}, n_{2}, c_{2}, n_{3}, c_{3}, n_{4}, c_{4}, where n_{i} and c_{i} are the number and the color in the ith card. There are only two colors red and black, respectively represented by the letter "r" and "b". The second line of each cases is two integers n and m(1 ≤ n, m ≤ 6), indicating the number of cards held by Sima Yi and Zhang Jiao. The third line is the imformations of the cards held by Sima Yi in specification n_{1} c_{1} n_{2} c_{2} ... n_{n} c_{n}. Then follows the last line in specification n_{1} c_{1} n_{2} c_{2} ... n_{m} c_{m}, indicating the imformations of the cards held by Zhang Jiao. All numbers in the cards are integers and range form 1 to 10. OutputFor each case, output a single line a string in specification X Wins!, where X is the winner of the game. Sample Input2 1 r 1 r 1 r 1 b 1 1 1 r 1 b 3 b 1 b 1 r 8 r 2 2 5 r 9 r 6 r 4 b Sample OutputZhang Jiao Wins! Sima Yi Wins! Author: LI, Dinghua Contest: ZOJ Monthly, January 2011 