#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,x,n) for(int i=x;i<=n;++i)
typedef pair<int,int> pii;
#define x first 
#define y second

const int N=3,_N=2e5+7;
struct mat
{
    ll m[N][N];
};

pii a[_N];
mat op[_N];

mat mul(mat A,mat B,int len)
{
    mat c;memset(c.m,0,sizeof c.m);
    for(ll i=0;i<len;++i)
        for(ll j=0;j<len;++j)
            for(ll k=0;k<len;++k)
            {
                c.m[i][j]=(c.m[i][j]+(A.m[i][k]*B.m[k][j]));
            }
    return c;
}

int main(){
    //freopen("1.in","r",stdin);
    int n;scanf("%d",&n);
    forn(i,1,n) scanf("%d%d",&a[i].x,&a[i].y);
    int m;scanf("%d",&m);
    forn(i,1,m){
        int t;scanf("%d",&t);
        mat _;memset(_.m,0,sizeof _.m);
        if(t==1){
            _.m[0][1]=-1;_.m[1][0]=1;_.m[2][2]=1;
            op[i] = mul(op[i-1],_,3);
        }else if(t==2){
            _.m[0][1]=1;_.m[1][0]=-1;_.m[2][2]=1;
            op[i]=mul(op[i-1],_,3);
        }else if(t==3){
            int p;scanf("%d",&p);
            _.m[0][0]=-1;_.m[1][1]=1;_.m[2][0]=2*p;_.m[2][2]=1;
            op[i]=mul(op[i-1],_,3);
        }else{
            int p;scanf("%d",&p);
            _.m[0][0]=1;_.m[1][1]=-1;_.m[2][1]=2*p;_.m[2][2]=1;
            op[i] = mul(op[i - 1],_,3);
        }
        if(i==1) op[i]=_;
    }
    int q;scanf("%d",&q);
    while(q--){
        int A,B;scanf("%d%d",&A,&B);
        if(A==0) printf("%d %d\n",a[B].x,a[B].y);
        else {
            mat gamma;memset(gamma.m,0,sizeof gamma.m);
            gamma.m[0][0]=a[B].x,gamma.m[0][1]=a[B].y,gamma.m[0][2]=1;
            gamma=mul(gamma,op[A],3);
            printf("%lld %lld\n",gamma.m[0][0],gamma.m[0][1]);
        }
    }
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define light ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define cases() ll t;cin>>t;while(t--)
#define all(c) c.begin(),c.end()
#define PI 3.14159265358979323846
const ll MAX = 2e5+5;
const ll INF = 1e18;
const ll MOD = 1e9+7;

vector<ll> a[MAX];
ll par[MAX],ans[MAX],sub[MAX],cnt;

void dfs1(ll node,ll parent)
{
    par[node] = parent;
    for(auto x:a[node])
    {
        if(x!=parent)
            dfs1(x,node);
    }
}

void dfs2(ll node,ll parent,ll carry)
{
    ans[node] = cnt+carry+sub[node];
    for(auto x:a[node])
    {
        if(x!=parent)
            dfs2(x,node,carry+sub[node]);
    }
}

int main()
{
    ll i,j,k,l,p,q,x,y,n;
    vector<pair<ll,ll>> edges;
    cin >> n;
    for(i=1;i<=n-1;i++)
    {
        cin >> x >> y;
        a[x].pb(y);a[y].pb(x);
        edges.pb({x,y});
    }
    dfs1(1,0);
    cin >> q;
    while(q--)
    {
        cin >> k >> x >> y;
        i = edges[x-1].first;j = edges[x-1].second; 
        cnt+=y;
        if(k==1)
        {
            if(par[j]==i)
                sub[j]-=y;
            else
            {
                sub[1]-=y;
                sub[i]+=y;
            }
        }
        else
        {
            if(par[i]==j)
                sub[i]-=y;
            else
            {
                sub[1]-=y;
                sub[j]+=y;
            }
        }
    }
    dfs2(1,0,0);
    for(i=1;i<=n;i++)
        cout << ans[i] << "\n";
}