#include "bits/stdc++.h"
#include <iomanip>

using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;
/*----------------------------------------------------------------*/
bool dp[200100][10] = {};
/*----------------------------------------------------------------*/
signed main(){

	int n;
	string s,x;
	cin >> n >> s >> x;

	dp[n][0] = 1;
	for(int i = n-1;i >= 0;i--){
		int cnt = 0;
		rep(j,10){
			bool a = dp[i+1][10*j%7];
			bool b = dp[i+1][(10*j+(s[i]-'0'))%7];
			if(x[i] == 'T' && (a||b)){
				dp[i][j] = true;
				cnt++;
			}
			if(x[i] == 'A' && (a&&b)){
				dp[i][j] = true;
				cnt++;
			}
		}
		if(cnt == 0){
			cout << "Aoki" << endl;
			return 0;
		}
	}
	if(dp[0][0])cout << "Takahashi" << endl;
	else cout << "Aoki" << endl;


	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://atcoder.jp/contests/agc048/tasks/agc048_a
// rm -r -f test;oj d https://atcoder.jp/contests/abc195/tasks/abc195_a

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int MAX = 2e5;

vector<map<int,int>> mp(MAX);

class Union_Find{
  vector<int> par; vector<int> rank; vector<int> num;
public:
  Union_Find(int n) {
    par = vector<int>(n); rank = vector<int>(n,0); num = vector<int>(n,1);
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if(par[x] == x) return x;
    else  return par[x] = find(par[x]);
  }
  int number(int x) {
    return num[find(x)];
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    num[x] += num[y];
    for(auto s : mp[y]) mp[x][s.first] += s.second;
    mp[y].clear();
  } 
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main(){
  int n, q;
  cin >> n >> q;
  int c[n];
  rep(i,n) {
    cin >> c[i];
    c[i]--;
    mp[i][c[i]]++;
  }
  Union_Find uf(n);
  vector<int> ans;
  rep(i,q) {
    int t, x, y;
    cin >> t >> x >> y;
    x--; y--;
    if(t == 1) uf.unite(x,y);
    else ans.push_back(mp[uf.find(x)][y]);
  }
  for(auto x : ans) cout << x << endl;
  return 0;
}
