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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

#define int long long int

#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
#define Graph vector<vi>
#define Graphw vector<vector<pair<int,int>>> 
#define sz(x) (int)x.size()
#define pr pair<int,int>
 
#define display(v) for(int i =0;i<(int)v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
#define read(a) for(int i = 0;i<(int)a.size();++i)cin>>a[i]
#define show(x) cout << #x << " is " << x << "\n";
// typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_si;
// typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_msi;
#define show_arr(a) cout << #a << "\n"; display(a) ; cout << "\n";
inline int add(int a, int b){ int c = (a%MOD) + (b%MOD); if(c >= MOD) c -= MOD; return c; }
inline int mul(int a, int b){ return ((a%MOD) * 1ll * (b%MOD)) % MOD; }
inline int sub(int a, int b){ int c = (a%MOD) - (b%MOD); if(c < 0) c += MOD; return c; }
const int nax = 200*1000 + 10;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//#define ook order_of_key
//#define fbo find_by_order
//   order_of_key(x) -> number of elements less than x.
// * find_by_order(x) -> gives the element at index x (0 - indexing)

void test_case();
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1; //cin>>t;
    while(t--){
        test_case();
    }
    return 0;
}


int n;
string s ,x;
int dp[nax][8];
int vis[nax][8];

bool f(int id , int cur){
    if(id >= n){
        return (cur == 0);
    }
    if(vis[id][cur]){
        return dp[id][cur];
    }
    vis[id][cur] = 1;
    int cur1 = (cur * 3)%7 + (s[id] - '0')%7;
    bool f1 = f(id + 1, cur1%7);
    int cur2 = cur * (3);
    bool f2 = f(id + 1 , cur2%7);
    //cout << cur1 << " " << cur2 << '\n';
    //cout << id << " " <<f1 << ' ' << f2 << '\n';
    if(x[id] == 'T'){
        if(f1 || f2){
            dp[id][cur] = 1;
        }
        else{
            dp[id][cur] = 0;
        }
    }
    else{
        if(f1 && f2){
            dp[id][cur] = 1;
        }
        else{
            dp[id][cur] = 0;
        }
    }
    return dp[id][cur];
}

void test_case(){
   
    cin>>n;
     
    cin>>s>>x;
    if(f(0 , 0)){
        cout << "Takahashi";
    }
    else{
        cout << "Aoki";
    }
    

}    

// Химаншу
// check overflow
// special case n == 1
// 🍪🍪🍪

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head

vector<bitset<256>> pre, now;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int u = 1<<n, v = u/2;
  cout << u-1 << endl;
  for(int i = 1; i <= n; i++) {
    now.clear();
    now.emplace_back(bitset<256>(0));
    rep(j, 1<<i-1) now[0].set(j);
    rep(j, pre.size()) {
      now.emplace_back(bitset<256>(0));
      now.back() |= pre[j];
      now.back() |= (pre[j]<<(1<<i-1));
    }
    rep(j, pre.size()) {
      now.emplace_back(bitset<256>(0));
      now.back() |= pre[j];
      now.back() |= ((pre[j]^now[0])<<(1<<i-1));
    }
    now.swap(pre);
  }
  for(auto bi:pre) {
    rep(i, u) {
      if(bi.test(i)) cout << 'A';
      else cout << 'B';
    }
    cout << '\n';
  }
}