Hide

Problem B
Better Dice

/problems/betterdice/file/statement/en/img-0001.png
A twenty-sided die with a special set of numbers on the faces. CC BY 4.0 by hamstermann on Thingiverse

The latest Table-Top Role Playing Game is out now: Better Dice. Unlike all other TTRPGs, this one is all about dice. In fact, it is all about the better die: decisions are made, friendships gained and lost, fights fought, battles won, all based on who has the better die.

This game uses special $n$-sided dice where each of the $n$ faces has the same probability of being rolled. Moreover, each die has its own special set of $n$ numbers on the faces.

While playing Better Dice you ended up in a very precarious situation where you must absolutely have a better die than your opponent, that is, you must roll higher than your opponent. Given both your die and your opponent’s die, decide who is more likely to roll a higher number.

Input

The input consists of:

  • One line with an integer $n$ ($1\leq n\leq 1000$), the number of sides on each die.

  • Two lines, each with $n$ integers $d$ ($1 \leq d \leq 10^9$), the values on one of the dice.

Output

Output “first” if the first die is more likely to roll a higher number than the second die. Output “second” if the second die is more likely to roll a higher number than the first die. Output “tie” if they are both equally likely to come up higher than the other.

Sample Input 1 Sample Output 1
2
4 6
5 5
tie
Sample Input 2 Sample Output 2
6
1 2 3 4 5 6
7 6 5 4 3 2
second
Sample Input 3 Sample Output 3
3
2 2 2
1 1 8
first

Please log in to submit a solution to this problem

Log in