#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll N;
	cin >> N;
	vector<pair<ll, ll>> edge(N - 1);
	vector<vector<ll>> g(N);
	for (ll i = 0; i < N - 1; i++)
	{
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
		edge[i] = {a, b};
	}
	vector<ll> depth(N, -1);
	depth[0] = 0;
	vector<ll> q = {0};
	while (q.size())
	{
		ll at = q.back();
		q.pop_back();
		for (ll i : g[at])
			if (depth[i] == -1)
			{
				depth[i] = depth[at] + 1;
				q.push_back(i);
			}
	}
	vector<ll> s(N);
	ll Q;
	cin >> Q;
	while (Q--)
	{
		ll t, e, x;
		cin >> t >> e >> x;
		ll a, b;
		tie(a, b) = edge[e - 1];
		if (depth[a] > depth[b])
		{
			swap(a, b);
			t ^= 3;
		}
		if (t == 1)
		{
			s[0] += x;
			s[b] -= x;
		}
		else
			s[b] += x;
	}
	q = {0};
	while (q.size())
	{
		ll at = q.back();
		q.pop_back();
		for (ll i : g[at])
			if (depth[at] < depth[i])
			{
				s[i] += s[at];
				q.push_back(i);
			}
	}
	for (ll i : s)
		cout << i << endl;
}
#include <iostream>
#include <climits>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <chrono>
#include <array>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

constexpr int INF = INT_MAX / 4;
constexpr ll LL_INF = LLONG_MAX / 4;
const double EPS = 1e-9;
const double PI = 2.0*acos(0.0);

struct transformation {
    array<array<ll, 3>, 2> m;
};

transformation unit  = {
        array<ll, 3>({1,0,0}),
        array<ll, 3>({0,1,0})
};

transformation r90_clockwise = {
        array<ll, 3>({0,1,0}),
        array<ll, 3>({-1,0,0})
};

transformation r90_counterclockwise = {
        array<ll, 3>({0,-1,0}),
        array<ll, 3>({1,0,0})
};

transformation reflection_x(ll p) {
    return {
            array<ll, 3>({-1,0,2*p}),
            array<ll, 3>({0,1,0})
    };
}

transformation reflection_y(ll p) {
    return {
            array<ll, 3>({1,0,0}),
            array<ll, 3>({0,-1,2*p})
    };
}


transformation mul(const transformation& a, const transformation& b) {
    return {
            array<ll, 3>({b.m[0][0] * a.m[0][0] + b.m[0][1] * a.m[1][0], b.m[0][0] * a.m[0][1] + b.m[0][1] * a.m[1][1], b.m[0][0] * a.m[0][2] + b.m[0][1] * a.m[1][2] + b.m[0][2]}),
            array<ll, 3>({b.m[1][0] * a.m[0][0] + b.m[1][1] * a.m[1][0], b.m[1][0] * a.m[0][1] + b.m[1][1] * a.m[1][1], b.m[1][0] * a.m[0][2] + b.m[1][1] * a.m[1][2] + b.m[1][2]})
    };
}

pair<ll,ll> calc(const transformation& a, const pair<ll,ll>& c) {
    return {a.m[0][0] * c.first + a.m[0][1] * c.second + a.m[0][2], a.m[1][0] * c.first + a.m[1][1] * c.second + a.m[1][2]};
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);


    int n, m, q;
    cin >> n;
    vector<pair<ll,ll>> c(n);
    for (int i = 0; i < n; i++) {
        ll a,b;
        cin >> a >> b;
        c[i] = {a,b};
    }

    cin >> m;
    vector<pair<int, int>> ops(m);
    for (int i = 0; i < m; i++) {
        int op;
        int p = 0;
        cin >> op;
        if (op == 3 || op == 4) {
            cin >> p;
        }
        ops[i] = {op, p};
    }

    cin >> q;
    vector<pair<ll, pair<ll, ll>>> queries(q);
    for (int i = 0; i < q; i++) {
        ll a,b;
        cin >> a >> b;
        queries[i] = {a, {i, b-1}};
    }

    vector<pair<ll,ll>> ans(q);

    sort(queries.begin(), queries.end());
    transformation cur_transformation = unit;

    int cur_q = 0;
    for (; cur_q < q && queries[cur_q].first == 0; cur_q++) {
        ans[queries[cur_q].second.first] = c[queries[cur_q].second.second]; // no transformation
    }

    for (ll i = 1; i <= m; i++) {
        transformation i_transformation = unit;
        switch (ops[i-1].first) {
            case 1:
                i_transformation = r90_clockwise;
                break;
            case 2:
                i_transformation = r90_counterclockwise;
                break;
            case 3:
                i_transformation = reflection_x(ops[i-1].second);
                break;
            default:
                i_transformation = reflection_y(ops[i-1].second);
                break;
        }

        cur_transformation = mul(cur_transformation, i_transformation);
        for (; cur_q < q && queries[cur_q].first == i; cur_q++) {
            ans[queries[cur_q].second.first] = calc(cur_transformation, c[queries[cur_q].second.second]); // no transformation
        }
    }

    for (int i = 0; i < q; i++) {
        cout << ans[i].first << " " << ans[i].second << "\n";
    }

    return 0;
}