#include<bits/stdc++.h>
using namespace std;
using ll = long long;

struct Matrix{
  vector<vector<ll>> M;
  Matrix(int H,int W):M(H,vector<ll>(W,0)){}
  Matrix(int H,int W,ll init):M(H,vector<ll>(W,init)){}

  void assign(int H,int W,ll init) { M.assign(H,vector<ll>(W,init)); }

  void build_E(){
    int h=M.size();
    int w=M[0].size();
    assign(h,w,0);
    for(int i=0;i<h&&i<w;i++){
      M[i][i]=1;
    }
  }

  // note:for 2D
  void build_rotR(){
    int h=M.size();
    int w=M[0].size();
    assign(h,w,0);
    M[0][0]=0;
    M[0][1]=1;
    M[1][0]=-1;
    M[1][1]=0;
  }

  // note:for 2D
  void build_rotL(){
    int h=M.size();
    int w=M[0].size();
    assign(h,w,0);
    M[0][0]=0;
    M[0][1]=-1;
    M[1][0]=1;
    M[1][1]=0;
  }

  Matrix operator*(Matrix a){
    int h1=M.size();
    int w1=M[0].size();
    int w2=a.M[0].size();
    Matrix res(h1,w2);
    for(int i=0;i<h1;i++){
      for(int j=0;j<w2;j++){
        for(int k=0;k<w1;k++){
          res[i][j]+=M[i][k]*a[k][j];
        }
      }
    }
    return res;
  }

  vector<ll>& operator[](int i){ return M[i]; }
};

int main(){
  int n;
  cin>>n;
  vector<Matrix> ms(n,Matrix(3,1));
  for(auto &m:ms){
    cin>>m[0][0]>>m[1][0];
    m[2][0]=1;
  }

  int m;
  cin>>m;
  const Matrix dim3(3,3,0);
  vector<Matrix> accum_m(m+1,dim3);
  accum_m[0].build_E();

  Matrix rotL(dim3);
  rotL.build_rotL();
  rotL[2][2]=1;

  Matrix rotR(dim3);
  rotR.build_rotR();
  rotR[2][2]=1;

  Matrix mx(dim3);
  mx.build_E();
  mx[0][0]=-1;

  Matrix my(dim3);
  my.build_E();
  my[1][1]=-1;

  for(int i=0;i<m;i++){
    int op,p;
    cin>>op;
    switch(op){
    case 1:
      accum_m[i+1]=rotR*accum_m[i];
      break;
    case 2:
      accum_m[i+1]=rotL*accum_m[i];
      break;
    case 3:
      cin>>p;
      mx[0][2]=2*p;
      accum_m[i+1]=mx*accum_m[i];
      break;
    case 4:
      cin>>p;
      my[1][2]=2*p;
      accum_m[i+1]=my*accum_m[i];
      break;
    }
  }

  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    ll a,b;
    cin>>a>>b;
    b--;
    Matrix ans=accum_m[a]*ms[b];
    cout<<ans[0][0]<<' '<<ans[1][0]<<'\n';
  }
}
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")
//#pragma GCC optimize("branch-target-load-optimize")
//#pragma GCC optimize("branch-target-load-optimize2")
//#pragma GCC optimize("btr-bb-exclusive")

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cassert>
#include <random>

using namespace std;

void solve();

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
}

#define int long long

const int N = 5e5 + 100, K = 3e5, A = 2e5 + 100, MOD = 1e9 + 7, base = 131, INF = 1e18;

int n, q, c[N], p[N], ans[N], sum;
vector < int > a[N];
vector < pair < int, int > > b;

void dfs(int v, int pp) {
    p[v] = pp;
    for (int i = 0; i < a[v].size(); i++) {
        int to = a[v][i];
        if (to == pp) continue;
        dfs(to, v);
    }
}

void dfs1(int v) {
    sum += c[v];
    ans[v] = sum;
    for (int i = 0; i < a[v].size(); i++) {
        int to = a[v][i];
        if (to == p[v]) continue;
        dfs1(to);
    }
    sum -= c[v];
}

void solve() {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int f, s;
        cin >> f >> s;
        f--, s--;
        a[f].push_back(s);
        a[s].push_back(f);
        b.push_back({f, s});
    }
    dfs(0, -1);

    cin >> q;
    while (q--) {
        int t, e, x;
        cin >> t >> e >> x;
        e--;
        if (t == 1) {
            int f = b[e].first, s = b[e].second;
            if (p[f] == s) {
                c[f] += x;
            } else {
                c[0] += x;
                c[s] -= x;
            }
        } else {
            int f = b[e].first, s = b[e].second;
            if (p[s] == f) {
                c[s] += x;
            } else {
                c[0] += x;
                c[f] -= x;
            }
        }
    }
    dfs1(0);
    for (int i = 0; i < n; i++) {
        cout << ans[i] << '\n';
    }
}

