#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define vvi vector<vector<int> >
const ll mod=998244353;
int n,m=1;
bool A(int i,int j){
	int x=i&j,cnt=0;
	do if(x&1)cnt++;
	while(x>>=1);
	return (cnt%2==0);
}
int main(){
	cin>>n;
	rep(i,n)m*=2;
	cout<<m-1<<endl;
	repp(i,m-1){
		rep(j,m){
			if(A(i,j))cout<<'A';
			else cout<<'B';
		}
		cout<<endl;
	}
	return 0;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
# define rep(i,a,b) for(int i=(a); i<=(b); ++i)
inline int readint(){
	int a = 0; char c = getchar(), f = 1;
	for(; c<'0'||c>'9'; c=getchar())
		if(c == '-') f = -f;
	for(; '0'<=c&&c<='9'; c=getchar())
		a = (a<<3)+(a<<1)+(c^48);
	return a*f;
}

const int MaxN = 200005;

int dp[MaxN][7]; // 1: T wins
char opt[MaxN], s[MaxN];

int dfs(int t,int x){
	if(~dp[t][x]) return dp[t][x];
	int &res = dp[t][x];
	if(opt[t] == 'A'){
		if(dfs(t+1,(10*x+s[t]-'0')%7)
			*dfs(t+1,(10*x)%7) == 0)
				return res = 0;
		return res = 1;
	}
	if(opt[t] == 'T'){
		if(dfs(t+1,(10*x+s[t]-'0')%7)
		or dfs(t+1,(10*x)%7) == 1)
			return res = 1;
		return res = 0;
	}
	return -1; // impossible
}

int main(){
	int n = readint();
	scanf("%s %s",s+1,opt+1);
	memset(dp,-1,sizeof(dp));
	rep(i,1,6) dp[n+1][i] = 0;
	dp[n+1][0] = 1;
	puts(dfs(1,0) ? "Takahashi" : "Aoki");
	return 0;
}