/**
 *    author:  FromDihPout
 *    created: 2021-06-22
**/

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    string s, x;
    cin >> n >> s >> x;
    
    reverse(s.begin(), s.end());
    reverse(x.begin(), x.end());
    vector<int> a(n);
    for (int i = 0, p = 1; i < n; i++, p = (p * 10) % 7) {
        a[i] = ((s[i] - '0') * p) % 7;
    }
    
    vector<bool> prev(7);
    if (x[0] == 'A' && a[0] == 0) {
        prev[0] = true;
    } else if (x[0] == 'T') {
        prev[0] = prev[7 - a[0]] = true;
    }
    for (int i = 1; i < n - 1; i++) {
        vector<bool> curr(7);
        for (int j = 0; j < 7; j++) {
            if (x[i] == 'A') {
                curr[j] = prev[(j + a[i]) % 7] && prev[j];
            } else {
                curr[j] = prev[(j + a[i]) % 7] || prev[j];
            }
        }
        prev = curr;
    }
    
    if (x[n - 1] == 'A') {
        cout << (prev[a[n - 1]] && prev[0] ? "Takahashi" : "Aoki") << '\n';
    } else {
        cout << (prev[a[n - 1]] || prev[0] ? "Takahashi" : "Aoki") << '\n';
    }
    return 0;
}
// 問題の URL を書いておく
// 

#include <bits/stdc++.h>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

using ll = long long;

// 0 なら高橋勝ち
// 1 なら青木勝ち
int calc(int round, int m, string& S, string& T, vector<vector<int>>& state)
{
    Print(round);
    Print(m);
    if(state[round][m] != -1) return state[round][m];

    // 最終ラウンド
    auto n = S[round] - '0';
    if(round == (int)state.size() - 1)
    {
        if(T[round] == 'A')
        {
            if(m != 0 || (m + n) % 7  != 0)
            {
                state[round][m] = 1;
            }
            else state[round][m] = 0;
        }
        else
        {
            if(m == 0 || (m + n) % 7  == 0)
            {
                state[round][m] = 0;
            } 
            else state[round][m] = 1;
        }

        Print(state[round][m]);
        return state[round][m];
    }


    if(T[round] == 'A')
    {
        if(calc(round + 1, (m * 10) % 7, S, T, state) == 1 || calc(round + 1, (m + n) * 10 % 7, S, T, state) == 1)
        {
            state[round][m] = 1;
            return 1;
        }
        state[round][m] = 0;
        return 0;
    }
    else
    {
        if(calc(round + 1, (m * 10) % 7, S, T, state) == 0 || calc(round + 1, (m + n) * 10 % 7, S, T, state) == 0)
        {
            state[round][m] = 0;
            return 0;
        }
        state[round][m] = 1;
        return 1;
    }
}

int main(int, const char**)
{
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;

    vector<vector<int>> state(N, vector<int>(7, -1));

    auto ans = calc(0, 0, S, T, state);
    Print(ans);
    cout << (ans == 0 ? "Takahashi" : "Aoki") << endl;
    return 0;
}
