N = int(eval(input()))



def grundy(x, k):

    while x % k != 0:

        p = max(1, (x - x // k * k) // (x // k + 1))

        x = x - (x // k + 1) * p

    return x // k



g = 0



for _ in range(N):

    a, k = list(map(int, input().split()))

    g ^= grundy(a, k)



print(('Takahashi' if g != 0 else 'Aoki'))
N = int(eval(input()))

g = 0

for _ in range(N):

    x, k = list(map(int, input().split()))

    while x % k != 0:

        x = x - (x // k + 1) * max(1, (x - x // k * k) // (x // k + 1))

    g ^= x // k

print(('Takahashi' if g != 0 else 'Aoki'))
N = int(eval(input()))


def grundy(x, k):
    while x % k != 0:
        p = max(1, (x - x // k * k) // (x // k + 1))
        x = x - (x // k + 1) * p
    return x // k


g = 0
for _ in range(N):
    a, k = list(map(int, input().split()))
    g ^= grundy(a, k)
print(("Takahashi" if g != 0 else "Aoki"))

N = int(eval(input()))
g = 0
for _ in range(N):
    x, k = list(map(int, input().split()))
    while x % k != 0:
        x = x - (x // k + 1) * max(1, (x - x // k * k) // (x // k + 1))
    g ^= x // k
print(("Takahashi" if g != 0 else "Aoki"))

- - -def grundy(x, k): -    while x % k != 0: -        p = max(1, (x - x // k * k) // (x // k + 1)) -        x = x - (x // k + 1) * p -    return x // k - - -    a, k = list(map(int, input().split())) -    g ^= grundy(a, k) +    x, k = list(map(int, input().split())) +    while x % k != 0: +        x = x - (x // k + 1) * max(1, (x - x // k * k) // (x // k + 1)) +    g ^= x // k