#include <iostream>
#include <iostream>
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define ll long long
#define li longll
#define pp pair<ll, ll> 
#define lb lower_bound
#define ub upper_bound
#define mk make_pair
#define pb push_back
#define llp(i, x, n) for (ll i = x; i < n; i++)
#define fr first
#define ss second
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define mod 1000000007
#define all(x) x.begin(), x.end()
using namespace std;
int main()
{
	fast;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int t;
	cin>>t;
	int c=0;
	string s1=s.substr(0,n);
	string s2=s.substr(n,n);
	while(t--)
	{
		
		int x,a,b;
		cin>>x>>a>>b;
		if(x==1)
		{
			a--,b--;
			if(a<n && b<n)
			swap(s1[a],s1[b]);
			else if(a>=n && b>=n)
			swap(s2[a-n],s2[b-n]);
			else
			swap(s1[a],s2[b-n]);
		}
		else
		{
		   swap(s1,s2);
		}
	}
	cout<<s1+s2<<endl;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; //required
using namespace std;
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define debug(x) cout << #x << " is " << x << endl
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
typedef long long ll;
const int MOD = 1e9 + 7;
int dp[200005][7];
int main(){
    fast;
    int n;
    cin >> n;
    string s, x;
    cin >> s >> x;
    // 1: Takahashi -1: Aoki
    for (int i = 0; i < 7; ++i){
        if (i){
            dp[n][i] = -1;
        }
        else{
            dp[n][i] = 1;
        }
    }
    int num, turn, mod1, mod2;
    for (int i = n - 1; i >= 0; --i){
        num = s[i] - '0';
        turn = x[i] == 'T' ? 1 : 0; // 1: Takahashi 0: Aoki
        for (int k = 0; k < 7; ++k){
            mod1 = (k * 10) % 7;
            mod2 = (mod1 + num) % 7;
            if (turn){ // T
                if (dp[i+1][mod1] == 1 or dp[i+1][mod2] == 1){
                    dp[i][k] = 1;
                }
                else{
                    dp[i][k] = -1;
                }
            } 
            else{ // A
                if (dp[i+1][mod1] == -1 or dp[i+1][mod2] == -1){
                    dp[i][k] = -1;
                }
                else{
                    dp[i][k] = 1;
                }
            }
        }
        
    }
    if (dp[0][0] == 1){
        cout << "Takahashi" << endl;
    }
    else{
        cout << "Aoki" << endl;
    }
    return 0;
}