AI Risk

Time limit: 0.05s Memory limit: 256MB Input: Output:

Tommaso and Filippo are bored, so they decide to play a game. Naturally, Filippo chooses his favourite board game: AI-Risk, a variant of the classic Risk set in a dystopian future where artificial intelligences have taken over the world.

Tommaso and Filippo have NN and MM developers, respectively, and want to distribute them among the territories on the game board. Since this is Tommaso’s first time playing AI-Risk, they decide to play with only three territories.

Figure 1: Tommaso and Filippo playing AI-Risk.\text{Figure 1: Tommaso and Filippo playing AI-Risk.}

Tommaso starts and distributes all his developers first. Then Filippo, after analysing Tommaso’s moves, distributes his own developers. For each territory, a player earns one point if they have at least as many developers there as the other player. The winner is the player with the most points.

Although it’s his first game, Tommaso plays optimally. Of course, Filippo – a seasoned AI-Risk player – does the same. Determine the winner of the game, or whether it ends in a draw.

Input data

The first line of the input file contains a single integer TT, the number of test cases. TT test cases follow, each preceded by an empty line.

Each test case consists of:

  • a line containing integers NN, MM.

Output data

The output file must contain TT lines corresponding to the test cases, each consisting of the lowercase name of winner (tommaso or filippo), or draw if the game ends in a draw.

Constraints and clarifications

  • 1T101 \leq T \leq 10;
  • 1N,M1 000 000 0001 \leq N, M \leq 1\ 000\ 000\ 000.
# Score Constraints
1 0 Examples
2 30 N,M30N, M \leq 30
3 30 N,M300N, M \leq 300
4 40 No additional constraints.

Example

stdin

2
3 3
7 6

stdout

draw
filippo

Explanation

In the first sample case, Tommaso can distribute his developers in three different ways:

  • [3,0,0][3, 0, 0]: Filippo can respond with [1,1,1][1, 1, 1], scoring 22 points to Tommaso’s 11 point.
  • [2,1,0][2, 1, 0]: Filippo can respond with [0,2,1][0, 2, 1], again scoring 22 points to Tommaso’s 11 point.
  • [1,1,1][1, 1, 1]: Filippo can respond with [1,2,0][1, 2, 0], resulting in both players scoring 22 points each.

It can be shown that the above responses of Filippo are optimal. Therefore, the best Tommaso can do is to play [1,1,1][1, 1, 1], leading to a draw.

In the second sample case, every possible distribution by Tommaso results in a win for Filippo. For example:

  • [7,0,0][7, 0, 0]: Filippo can respond with [3,2,1][3, 2, 1], scoring 22 points to Tommaso’s 11 point.
  • [3,3,1][3, 3, 1]: Filippo can respond with [0,4,2][0, 4, 2], again scoring 22 points to Tommaso’s 11 point.

Log in or sign up to be able to send submissions!