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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll,ll>
#define pii pair<int ,int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define forn(i,s,e) for(int i = s; i < (e); ++i)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILEIO                          \
freopen("./input.txt", "r", stdin); \
freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                   \
for (                                                                   \
auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second;                                               \
debug("%s : %lld ms\n ", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
const int M = 1e9 + 7;

template <class T> T ABS(const T &x) {return x>0? x:-x;}
ll gcd(ll n1, ll n2) {return n2==0? ABS(n1) : gcd(n2,n1%n2);}
ll lcm(ll n1, ll n2) {return n1==0 && n2==0? 0 : ABS(n1*n2)/gcd(n1,n2);}
ll ceil2(ll a, ll b) {return (a + b - 1) / b;}

void bad(){
    cout << "UNSOLVABLE\n";
    exit(0);
}

int main()
{
FASTIO
#ifdef LOCAL
FILEIO
#endif
    vector<string> s(3);
    for(auto &x: s) cin >> x;

    vector<char> dict;
    for(auto &v: s) for(auto &c: v) dict.push_back(c);
    sort(dict.begin(),dict.end());
    dict.erase(unique(dict.begin(), dict.end()), dict.end());
    if(dict.size() > 10) bad();

    for(auto &v: s) for(auto &c: v) c = 'a' + lower_bound(dict.begin(),dict.end(),c) - dict.begin();

    vi index(10);
    iota(index.begin(),index.end(),0);
    do{
        auto U = s;
        for(auto &v: U) for(auto &c: v) c = '0' + index[c - 'a'];
        ll a = stoll(U[0]), b = stoll(U[1]), c = stoll(U[2]);
        if(U[0][0] != '0' && U[1][0] != '0' && U[2][0] != '0'  && a +b == c){
            cout << a << '\n' << b << '\n' << c << '\n';
            return 0;
        }

    } while(next_permutation(index.begin(),index.end()));
    bad();

    return 0;
}
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5+100;
int dp[N][7], a[N], n;
string s, t;
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> s >> t;
	s = "@" + s;
	t = "@" + t + "T";
	int p = 1;
	for(int i = n; i >= 1; --i) {
		a[i] = p * (s[i] - '0') % 7;
		p = p * 10 % 7;
	}
	dp[n+1][0] = 1;
	for(int i = n; i >= 0; --i) {
		for(int mod = 0; mod < 7; ++mod) {
			if(t[i+1] == 'T') {
				dp[i][mod] = dp[i+1][mod] | dp[i+1][(mod + a[i+1]) % 7];
			} else {
				dp[i][mod] = dp[i+1][mod] & dp[i+1][(mod + a[i+1]) % 7];
			}
		}
	}
	if(dp[0][0]) {
		cout << "Takahashi\n";
	} else {
		cout << "Aoki\n";
	}
}