4079.Industrial Nim

Time Limit: 1s Memory Limit: 256MB

There are n stone quarries in Petrograd.

Each quarry owns mi dumpers (1 \le i \le n). It is known that the first dumper of the i-th quarry has xi stones in it, the second dumper has xi+1 stones in it, the third has xi+2, and the mi-th dumper (the last for the i-th quarry) has xi+mi-1 stones in it.

Two oligarchs play a well-known game Nim. Players take turns removing stones from dumpers. On each turn, a player can select any dumper and remove any non-zero amount of stones from it. The player who cannot take a stone loses.

Your task is to find out which oligarch will win, provided that both of them play optimally. The oligarchs asked you not to reveal their names. So, let's call the one who takes the first stone «tolik» and the other one «bolik».

Input Format(From the terminal/stdin)

The first line of the input contains one integer number n (1 \le n \le 105) - the amount of quarries. Then there follow n lines, each of them contains two space-separated integers xi and mi (1 \le xi,mi \le 1016) - the amount of stones in the first dumper of the i-th quarry and the number of dumpers at the i-th quarry.

Output Format(To the terminal/stdout)

Output «tolik» if the oligarch who takes a stone first wins, and «bolik» otherwise.

Sample Input 1

Copy
2
2 1
3 2
 \n
 · \n
 · \n

Sample Output 1

Copy
tolik
     \n

Sample Input 2

Copy
4
1 1
1 1
1 1
1 1
 \n
 · \n
 · \n
 · \n
 · \n

Sample Output 2

Copy
bolik
     \n

Submit

请先 登录

© 2025 FAQs