#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
#define pb push_back
#define T ll testx; cin>>testx; while(testx--)
#define print(name) for(auto t:name){cout<<t<<" ";}cout<<endl;
#define printii(name) for(auto t:name){cout<<t.first<<" "<<t.second<<endl;}
#define mod 1000000007
#define modx 998244353
#define inf 2000000000000000000
#define mem(name,val) memset(name,val,sizeof(name))
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define endl "\n"
#define popcount(x) __builtin_popcountll(x)
#define precise cout<<fixed<<setprecision(15)
const long double pi = acos(-1);
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
   int n,x,a,b;cin>>n;
   string s;cin>>s;
   string s1=s.substr(0,n);
   string t=s.substr(n);
   int q;cin>>q;
   ll ok=1;
   while(q--)
   {
    cin>>x>>a>>b;
    if(x==1){
      a--;b--;
      if(ok==1){
    if(a<=n-1&&b<=n-1)
    {
      swap(s1[a],s1[b]);
    }
    else if(a<=n-1&&b>n-1)
    {
      b-=n;swap(s1[a],t[b]);
    }
    else
    {
      a-=n;b-=n;swap(t[a],t[b]);
    }
  }
  else
  {
    if(a<=n-1&&b<=n-1)
    {
      swap(t[a],t[b]);
    }
    else if(a<=n-1&&b>n-1)
    {
      b-=n;swap(t[a],s1[b]);
    }
    else
    {
      a-=n;b-=n;swap(s1[a],s1[b]);
    } 
  }
  }
    else
    {
      ok=1-ok;
    }
   }
   if(ok){cout<<s1<<t;}else{cout<<t<<s1;}
   
}
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
const int maxn=2e5+4;
vector <int>e[maxn];
int dep[maxn];
ll bt[maxn];
struct node{
    int u,v;
}ee[maxn];
void dfs(int u,int pa){
    dep[u]=dep[pa]+1;
    for(auto v:e[u]){
        if(v!=pa)dfs(v,u);
    }
}
void dfs2(int u,int pa){
    for(auto v:e[u]){
        if(v!=pa){
            bt[v]+=bt[u];
            dfs2(v,u);
        }
    }
}
void f(int u,int v,int x){
    if(dep[u]>dep[v]){
        bt[u]+=x;
    }
    else{
        bt[1]+=x;
        bt[v]-=x;
    }
}
int main(){
    int n;
    scanf("%d",&n);

    for(int i=1;i<n;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        ee[i].u=u;ee[i].v=v;
        e[u].pb(v);
        e[v].pb(u);
    }
    dfs(1,0);
    int q;
    scanf("%d",&q);
    for(int i=1;i<=q;i++){
        int t,id,x;
        scanf("%d%d%d",&t,&id,&x);
        int u=ee[id].u,v=ee[id].v;
        if(t==2)swap(u,v);
        f(u,v,x);
    }
    dfs2(1,0);
    for(int i=1;i<=n;i++)
        printf("%lld\n",bt[i]);

    return 0;
}

