#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
#define PI 3.141592653589793
//#define MOD 1000000007
#define MOD 998244353
#define ALL(obj) (obj).begin(),(obj).end()
const ll INF = 1LL << 60;
const int inf = 1 << 30;
//四方向への移動ベクトル
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}


int main(){
    ll n,ans=0,sc=0;
    cin >> n;
    string s,t;
    cin >> s >> t;
    queue<ll> que;
    queue<ll> que2;
    for (ll i=0;i<n;i++){
        if (t[i]=='1')que.push(i);
        if (s[i]=='1'){
            if (!que2.empty()){
                ans+=i-que2.front();
                que2.pop();
            }else if (que.empty()){
                que2.push(i);
            }else{
                ans+=i-que.front();
                que.pop();
            }
        }
    }
    if (que.empty() and que2.empty()){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD int(1e9+7)
#define INF int(1e9+7)
#define LINF ll(1e18+7)
#define PI acos(-1)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<ll,ll>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

vector<int> dp[210000];

int main(){
  int n;
  string s;
  string x;
  cin>>n>>s>>x;
  dp[n].push_back(0);
  for(int i=n-1; i>=0; i--){
    if(x[i]=='A'){
      rep(r,7){
        bool a=0, b=0;
        for(auto p : dp[i+1]){
          if(10*r%7==p) a=1;
          if((10*r+s[i]-'0')%7==p) b=1;
        }
        if(a && b) dp[i].push_back(r);
      }
    }else{
      rep(r,7){
        for(auto p : dp[i+1]){
          if(10*r%7==p || (10*r+s[i]-'0')%7==p){
            dp[i].push_back(r);
            break;
          }
        }
      }
    }
  }
  for(auto x : dp[0]){
    if(x==0){
      cout<<"Takahashi"<<endl;
      return 0;
    }
  }
  cout<<"Aoki"<<endl;
}