#include<bits/stdc++.h>
using namespace std;
#define reg register
typedef long long ll;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)
static char buf[100000],*p1=buf,*p2=buf;
inline ll read(void){
	reg bool f=false;
	reg char ch=getchar();
	reg ll res=0;
	while(!isdigit(ch))f|=(ch=='-'),ch=getchar();
	while(isdigit(ch))res=10ll*res+(ch^'0'),ch=getchar();
	return f?-res:res;
}

ll n;
int cnt[3];

int main(void){
	n=read();
	reg int tmp=n%3;
	while(n){
		++cnt[(n%10)%3];
		n/=10;
	}
	reg int sum=cnt[0]+cnt[1]+cnt[2];
	if(!tmp)
		puts("0");
	else if(tmp==1)
		if(cnt[1]>0&&sum>1)
			puts("1");
		else if(cnt[2]>1&&sum>2)
			puts("2");
		else
			puts("-1");
	else
		if(cnt[2]>0&&sum>1)
			puts("1");
		else if(cnt[1]>1&&sum>2)
			puts("2");
		else
			puts("-1");
	return 0;
}
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <optional>
#include <utility>
#include <vector>
#include <cmath>
// #include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif

template <class S, class T> bool chmax(S& x, const T& y){ if(x < y){ x = y; return true; } return false; }
template <class S, class T> bool chmin(S& x, const T& y){ if(x > y){ x = y; return true; } return false; }

struct nimotsu {
    int size, value;
};

int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    
    int n; std::string S, X; std::cin >> n >> S >> X;
    // 確実にできるか
    constexpr std::array<char, 7> D = {0 % 7, 10 % 7, 20 % 7, 30 % 7, 40 % 7, 50 % 7, 60 % 7};
    const auto seven_mod = [](char a){ return (a < 7) ? a : a - 7; };
    auto dfs = [&](auto self, int index) -> char {
        if(index == n) return 1;
        const char np = self(self, index + 1); if(np == 0) return 0;
        S[index] -= '0'; if(S[index] >= 7) S[index] -= 7;
        short res = 0;
        // Aoki doesn't want to make the number to be nine times
        if(X[index] == 'A'){
            for(char i = 0; i < 7; ++i) if( (np >> D[i]) & (np >> seven_mod(D[i] + S[index])) & 1) res |= (1 << i);
        }
        else{
            for(char i = 0; i < 7; ++i) if( ((np >> D[i]) | (np >> seven_mod(D[i] + S[index]))) & 1) res |= (1 << i);
        }
        return res;
    };
    const short res = dfs(dfs, 0);
    std::cout << ((res & 1) ? "Takahashi" : "Aoki" ) << '\n';
    return 0;
}