#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)

#define rep(i, a, b) for(int i = a; i <= b; i++)
#define rrep(i, a, b) for(int i = b; i >= a; i --)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b)) 

#define MAXN 1000005
#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)

#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())

using namespace std;

#ifdef wiwihorz
#define print(a...) kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) {
	while(L < R) cerr << *L << " \n"[next(L) == R], ++L;
}
void kout() {cerr << endl;}
template<class T1, class ... T2> void kout(T1 a, T2...e) {cerr << a << " ", kout(e...);}
#else 
#define print(...) 0
#define vprint(...) 0
#endif
int n, m;
struct edge {
	int to, cost;
};
vector<vector<edge>> mp;
vector<int> dis, vis;
int dikstra(int x, int y) {
	dis.assign(2 * n + 1, INF);
	vis.assign(2 * n + 1, 0);
//	print(2 * n + 1, dis.size());
	priority_queue<pii, vector<pii>, greater<pii>> pq;
	dis[x] = 0; pq.push({0, x});
	while(pq.size()) {
		int cur = pq.top().second; pq.pop();
		if(vis[cur]) continue;
		vis[cur] = 1;
		for(auto i : mp[cur]) {
			if(dis[i.to] > dis[cur] + i.cost) {
				dis[i.to] = dis[cur] + i.cost;
				pq.push({dis[i.to], i.to});
			}
		}
	}
//	print(x, y, dis.size());
//	vprint(all(dis)), kout();
	if(dis[y] == INF) return -1;
	else return dis[y];
}
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	mp.assign(2 * n + 5, vector<edge>());
	rep(i, 1, n) {
		mp[i].push_back({i + n, 0});
	}
	rep(i, 1, m) {
		int a, b, c; 
		cin >> a >> b >> c;
		mp[a + n].push_back({b, c});
	}
	rep(i, 1, n) {
		cout << dikstra(i + n, i) << "\n";
	}
	return 0;
}
#include <bits/stdc++.h>
 
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION cout << fixed << setprecision(20);
 
using namespace std;

void solve() {
    int n;
    cin >> n;
    string s;
    string x;
    cin >> s >> x;

    vector<vector<int>> dp(n, vector<int>(7, -1));

    function<int(int,int)> get = [&](int pos, int rem) {
        if (pos == n) return int(rem == 0);

        if (dp[pos][rem] == -1) {
            int ans1 = get(pos + 1, (rem * 10) % 7);
            int ans2 = get(pos + 1, (rem * 10 + (s[pos] - '0')) % 7);

            if (x[pos] == 'A') dp[pos][rem] = min(ans1, ans2);
            if (x[pos] == 'T') dp[pos][rem] = max(ans1, ans2);
        }

        return dp[pos][rem];
    };
    
    int ans = get(0, 0);

    if (ans) {
        cout << "Takahashi\n";
    } else {
        cout << "Aoki\n";
    }
}

int main() {
    FASTIO;
    PRECISION;

    int t = 1;
    // cin >> t;

    for (int i = 1; i <= t; i++) {
        solve();
    }
}