#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int ll
const int MAX = 2e5 + 10;
const int modn = 1e9 + 7;
const int INF = 0x3f3f3f3f3f3f;
int a[MAX];
int n;
void init(){
    int ans=1;
    for(int i=n-1;i>=0;i--){
        a[i]=ans%7;
        ans=(ans*10)%7;
    }
}
int f[MAX][10];
void solve() {
    cin>>n;
    init();
    string s,op;
    cin>>s>>op;
    f[n][0]=1;
    for(int i=n-1;i>=0;i--){
        int shu=s[i]-'0';
        if(op[i]=='A'){
            for(int j=0;j<7;j++){
                if(f[i+1][j]&&f[i+1][(j+a[i]*shu)%7])f[i][j]=1;
            }
        }else{
            for(int j=0;j<7;j++){
                if(f[i+1][j]||f[i+1][(j+a[i]*shu)%7])f[i][j]=1;
            }
        }
    }
    if(f[0][0]){
        cout<<"Takahashi";
    }else{
        cout<<"Aoki";
    }
}

signed main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int _ = 1;
    //cin >> _;
    for (int i = 1; i <= _; i++) {

        solve();
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define d long double

#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%Lf",&n)
#define pri(n) printf("%d ",(int)n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%Lf ",n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define dprin(n) printf("%Lf\n",n)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define all(x) x.begin(),x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define bitcount(n) __builtin_popcount(n)
#define tc   int tt; scf(tt); while(tt--)
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264

const ll M =1e9+7;
const int N = 1e6+7;

vector<ll>adj[N];
ll c[N];
ll n;
ll in[N];
bool visited[N];
ll timer=0;
ll temp[N];
ll a[N],b[N];

void dfs(ll x)
{
    visited[x]=true;

    in[x]=timer++;

    for(auto it: adj[x])
    {
        if(!visited[it])
        dfs(it);
    }
}

void dfs1(ll x,ll sum)
{
    sum+=temp[x];

    visited[x]=true;

    c[x]=sum;

    for(auto it: adj[x])
    {
        if(!visited[it])
        {
            dfs1(it,sum);
        }
    }
}

int main()
{
    cin>>n;

    rep(i,0,n-1)
    {
        cin>>a[i]>>b[i];

        adj[a[i]].pb(b[i]);
        adj[b[i]].pb(a[i]);
    }

    dfs(1);

    ll q;
    cin>>q;

    while(q--)
    {
        ll type,e,x;

        cin>>type>>e>>x;

        if(type==1)
        {
            if(in[a[e-1]]<in[b[e-1]])
            {
                temp[1]+=x;
                temp[b[e-1]]-=x;
            }
            else
            {
                temp[a[e-1]]+=x;
            }
        }
        else
        {
            if(in[b[e-1]]<in[a[e-1]])
            {
                temp[1]+=x;
                temp[a[e-1]]-=x;
            }
            else
            {
                temp[b[e-1]]+=x;
            }
        }
    }

    clr(visited);
    dfs1(1,0);

    rep(i,1,n+1)
    cout<<c[i]<<endl;

return 0;
}