#P1168. Er Ba Game
Er Ba Game
Background
2021nowcoder多校day2 数据手造,如果想品尝原汁原味的数据,请在nowcoder购买
Description
Er Ba Game is a popular card game in China's Province Zhejiang.
In this problem, the game involves two players and 36 cards , each with four.
In the game each player takes 2 cards , .Player gets . Suppose , and we determine the winner as follow:
- is the biggest pair.
- If neither is , a pair with is greater than a pair without.
- If and , then compare .The bigger one wins.
- If , compare $(a_1+b_1)\ \text{mod}\ 10,(a_2+b_2)\ \text{mod}\ 10$.The bigger one wins.
- If and $(a_1+b_1)\ \text{mod}\ 10=(a_2+b_2)\ \text{mod}\ 10$,compare.The bigger one wins.
If does not hold, we can exchange and or exchange and until the formula holds.
You're told , and you should tell who's gonna win the game.
Format
Input
The first line contains an integer — number of game cases. Then lines, each contains four integers , denoting the cards of each player.
Output
Output lines.
If player 1 wins, output "first" (without quote).
If player 2 wins, output "second" (without quote).
Otherwise, output "tie" (without quote).
Samples
5
2 8 4 6
6 6 6 7
4 5 5 5
6 3 9 10
7 2 2 7
first
first
second
second
tie
The answers to the first four sets of data are obtained through the first, second, second, and fifth rules respectively.
Limitation
1s, 1024KiB for each test case
It's guaranteed that .
It's not guaranteed that .