#include <bits/stdc++.h>
using namespace std;

const int maxn = 1010;

int n;
int st[maxn], ed[maxn];
vector<int> vc[maxn];

bool check (int s, int t, int L)
{
    if (s + L * 2 - 1 > 2 * n) return false;
    for (int u = s; u < t; u++)
    {
        int v = u + L;
        if (st[v] || ed[u]) return false;
        if ((st[u] == 0 && ed[v] <= 0) || (st[u] <= 0 && ed[v] == 0) || (st[u] == v)) continue;
        return false;
    }
    return true;
}

bool dp[maxn];

int main()
{
    //freopen("C:/Users/MACHENIKE/Desktop/data.in","r",stdin);
    scanf ("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        int u, v;
        scanf ("%d %d", &u, &v);
        if (u >= v && v != -1) return puts ("No"), 0;
        if (~u && (st[u] || ed[u])) return puts ("No"), 0;
        if (~v && (st[v] || ed[v])) return puts ("No"), 0;
        if (~u) st[u] = v;
        if (~v) ed[v] = u;
    }
    for (int i = 1; i <= n * 2; i++)
    {
        for (int j = i + 1; j <= n * 2; j++)
        {
            int len = j - i;
            if (i + len * 2 - 1 > n * 2) break;
            if (check (i, j, len))
            {
                //printf ("%d %d %d\n", i, j, len);
                vc[i + len * 2 - 1].push_back (i);
            }
        }
    }
    dp[n * 2 + 1] = 1;
    for (int i = n * 2; i >= 1; i--)
    {
        if (!dp[i + 1]) continue;
        //printf ("%d : ", i);
        for (auto it : vc[i])
        {
            dp[it] = 1;
            //printf ("%d ", it);
        }
       // puts("");
    }
    if (dp[1]) puts ("Yes");
    else puts ("No");
    return 0;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
# define rep(i,a,b) for(int i=(a); i<=(b); ++i)
inline int readint(){
	int a = 0; char c = getchar(), f = 1;
	for(; c<'0'||c>'9'; c=getchar())
		if(c == '-') f = -f;
	for(; '0'<=c&&c<='9'; c=getchar())
		a = (a<<3)+(a<<1)+(c^48);
	return a*f;
}

const int MaxN = 200005;

int dp[MaxN][7]; // 1: T wins
char opt[MaxN], s[MaxN];

int dfs(int t,int x){
	if(~dp[t][x]) return dp[t][x];
	int &res = dp[t][x];
	if(opt[t] == 'A'){
		if(dfs(t+1,(10*x+s[t]-'0')%7)
			*dfs(t+1,(10*x)%7) == 0)
				return res = 0;
		return res = 1;
	}
	if(opt[t] == 'T'){
		if(dfs(t+1,(10*x+s[t]-'0')%7)
		or dfs(t+1,(10*x)%7) == 1)
			return res = 1;
		return res = 0;
	}
	return -1; // impossible
}

int main(){
	int n = readint();
	scanf("%s %s",s+1,opt+1);
	memset(dp,-1,sizeof(dp));
	rep(i,1,6) dp[n+1][i] = 0;
	dp[n+1][0] = 1;
	puts(dfs(1,0) ? "Takahashi" : "Aoki");
	return 0;
}