#include <bits/stdc++.h>
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    i64 n;
    std::cin >> n;
    std::string s, t;
    std::cin >> s;
    std::cin >> t;
    std::vector<int> a, b;
    for (int i = 0; i < n; i++) {
        if (s[i] == '0') {
            a.push_back(i);
        }
        if (t[i] == '0') {
            b.push_back(i);
        }
    }
    if (a.size() != b.size()) {
        std::cout << "-1\n";
        return 0;
    }
    int ans = 0;
    for (int i = 0; i < int(a.size()); i++) {
        ans += (a[i] != b[i]);
    }
    std::cout << ans << "\n";
    return 0;
}
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

bitset<7> dp[201010];

int main(){
   int n;
   cin>>n;
   string s,t;
   cin>>s>>t;
   
   dp[n]=1;
   for(int i=n-1;i>=0;i--){
      if(t[i]=='A'){
         rep(x,0,7)dp[i][x]=1;
         rep(x,0,7){
            if(!dp[i+1][(10*x+(s[i]-'0'))%7]){
               dp[i][x]=0;
            }
            if(!dp[i+1][(10*x)%7]){
               dp[i][x]=0;
            }
         }
      }
      else{
         rep(x,0,7){
            if(dp[i+1][(10*x+(s[i]-'0'))%7]){
               dp[i][x]=1;
            }
            if(dp[i+1][(10*x)%7]){
               dp[i][x]=1;
            }
         }
      }
   }
   if(dp[0][0])puts("Takahashi");
   else puts("Aoki");
   return 0;
}