#include <bits/stdc++.h>

using namespace std;

// clang-format off
/* accelration */
// 高速バイナリ生成
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
// cin cout の結びつけ解除, stdioと同期しない(入出力非同期化)
// cとstdの入出力を混在させるとバグるので注意
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;

/* alias */
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vs = vector<string>;
using pii = pair<int, int>;

/* define short */
#define pb push_back
#define mp make_pair
#define all(obj) (obj).begin(), (obj).end()
#define YESNO(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(bool) if(bool){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

/* REP macro */
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) reps(i, 1, n + 1)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define rrepd(i,n) for(ll i=n;i>=1;i--)

/* debug */
// 標準エラー出力を含む提出はrejectされる場合もあるので注意
#define debug(x) cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << "\033[m" << endl;

/* func */
inline int in_int() {int x; cin >> x; return x;}
inline ll in_ll() {ll x; cin >> x; return x;}
inline string in_str() {string x; cin >> x; return x;}
// search_length: 走査するベクトル長の上限(先頭から何要素目までを検索対象とするか、1始まりで)
template <typename T> inline bool vector_finder(std::vector<T> vec, T element, unsigned int search_length) {
    auto itr = std::find(vec.begin(), vec.end(), element);
    size_t index = std::distance( vec.begin(), itr );
    if (index == vec.size() || index >= search_length) {return false;} else {return true;}
}
template <typename T> inline void print(const vector<T>& v, string s = " ")
    {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template <typename T, typename S> inline void print(const pair<T, S>& p)
    {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << "\n";}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v)
    {for (auto&& p : v) print(p);}
// 第一引数と第二引数を比較し、第一引数(a)をより大きい/小さい値に上書き
template <typename T> inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;}
template <typename T> inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;}

int main(){
    int n;
    cin >> n;

    vector<int> a(n);
    vector<int> b(n);

    rep(i, n) cin >> a[i] >> b[i];

    int mina = 1000000;
    int minb = 1000000;
    int ap;
    rep(i, n) {
        if(mina > a[i]) {
            mina = a[i]; 
            ap = i;
        }
    }
    b[ap] += mina;

    rep(i, n){
        if(minb > b[i]){
            minb = b[i];
        }
    }

    cout << max(mina, minb) << endl;



}
#include<iostream>
using namespace std;
string s,t;
int n,a[200010],b[200010],shi[10]={1,10,100,-1,-10,-100},f[200010][10];
int dfs(int x,int y)
{
	int t1,t2;
	if(f[x][y]!=0) return f[x][y];
	if(b[x]==1)
	{
		t1=dfs(x+1,y);
		t2=dfs(x+1,(y+a[x])%7);
		if(t1==1||t2==1)
		 return f[x][y]=1;
		else
		 return f[x][y]=-1;
	}
	else
	{
		t1=dfs(x+1,y);
		t2=dfs(x+1,(y+a[x])%7);
		if(t1==-1||t2==-1)
		 return f[x][y]=-1;
		else
		 return f[x][y]=1;
	}
}
int main()
{
	int i,j;
	cin>>n;
	cin>>s>>t;
	for(i=0;i<n;i++) 
	{
		a[i+1]=((s[i]-'0')*shi[(n-i-1)%6])%7;
		a[i+1]=(a[i+1]+7)%7;
		if(t[i]=='A') b[i+1]=1; else b[i+1]=-1;
	}
	//for(i=1;i<=n;i++) cout<<a[i];
	//cout<<endl;
	f[n+1][0]=-1;
	for(i=1;i<7;i++) f[n+1][i]=1;
	dfs(1,0);
	/*for(i=1;i<=n+1;i++)
	{
	 for(j=0;j<7;j++)
	  cout<<f[i][j]<<" ";
	  cout<<endl;
}*/
 	if(f[1][0]==1) cout<<"Aoki";
	else cout<<"Takahashi";
}