#ARC091D. [ARC091F] Strange Nim

[ARC091F] Strange Nim

Score : 900900 points

Problem Statement

Takahashi and Aoki are playing a stone-taking game. Initially, there are NN piles of stones, and the ii-th pile contains AiA_i stones and has an associated integer KiK_i.

Starting from Takahashi, Takahashi and Aoki take alternate turns to perform the following operation:

  • Choose a pile. If the ii-th pile is selected and there are XX stones left in the pile, remove some number of stones between 11 and floor(X/Ki)floor(X/K_i) (inclusive) from the pile.

The player who first becomes unable to perform the operation loses the game. Assuming that both players play optimally, determine the winner of the game. Here, floor(x)floor(x) represents the largest integer not greater than xx.

Constraints

  • 1N2001 \leq N \leq 200
  • 1Ai,Ki1091 \leq A_i,K_i \leq 10^9
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 K1K_1

::

ANA_N KNK_N

Output

If Takahashi will win, print Takahashi; if Aoki will win, print Aoki.

2
5 2
3 3
Aoki

Initially, from the first pile at most floor(5/2)=2floor(5/2)=2 stones can be removed at a time, and from the second pile at most floor(3/3)=1floor(3/3)=1 stone can be removed at a time.

  • If Takahashi first takes two stones from the first pile, from the first pile at most floor(3/2)=1floor(3/2)=1 stone can now be removed at a time, and from the second pile at most floor(3/3)=1floor(3/3)=1 stone can be removed at a time.
  • Then, if Aoki takes one stone from the second pile, from the first pile at most floor(3/2)=1floor(3/2)=1 stone can be removed at a time, and from the second pile no more stones can be removed (since floor(2/3)=0floor(2/3)=0).
  • Then, if Takahashi takes one stone from the first pile, from the first pile at most floor(2/2)=1floor(2/2)=1 stone can now be removed at a time, and from the second pile no more stones can be removed.
  • Then, if Aoki takes one stone from the first pile, from the first pile at most floor(1/2)=0floor(1/2)=0 stones can now be removed at a time, and from the second pile no more stones can be removed.

No more operation can be performed, thus Aoki wins. If Takahashi plays differently, Aoki can also win by play accordingly.

3
3 2
4 3
5 1
Takahashi
3
28 3
16 4
19 2
Aoki
4
3141 59
26535 897
93 23
8462 64
Takahashi