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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
	const int MAXIOSIZE = 1 << 24 | 1;
	unsigned char buf[MAXIOSIZE], *p1, *p2;
	#define gc (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2) ? EOF : *p1++)
	template <typename T> void read(T& x) {
		x = 0; char ch = gc; bool flg = false;
		for (; ch < '0' || '9' < ch; ch = gc) if (ch == '-') flg |= true;
		for (; '0' <= ch && ch <= '9'; ch = gc) x = x * 10 + ch - '0';
		flg ? x = -x : 0;
	}
	template <typename T> void out(const T& x) { if (x > 9) out(x / 10); putchar(x % 10 + '0'); }
	template <typename T> inline void write(const T& x, const char& ed = ' ') { if (x < 0) putchar('-'), out(-x); else out(x); putchar(ed); }
}

typedef long long ll;

const int MAXN = 2e5 + 10;
const int MAXLOG = 18 + 10;

int n, q;
vector<int> E[MAXN];
pair<int, int> Edge[MAXN];

int dfsclock, dtp[MAXN];
struct Vertex { int dfn, dep, sz, fa[MAXLOG]; ll val; } vtx[MAXN];

void dfs(int u) {
	dtp[ vtx[u].dfn = ++dfsclock ] = u, vtx[u].sz = 1;
	rep(i, 1, 18) vtx[u].fa[i] = vtx[vtx[u].fa[i - 1]].fa[i - 1];
	vtx[u].dep = vtx[vtx[u].fa[0]].dep + 1;
	for (int v : E[u]) {
		if (v == vtx[u].fa[0]) continue;
		vtx[v].fa[0] = u;
		dfs(v); vtx[u].sz += vtx[v].sz;
	}
}

bool anc_son(int u, int v) { return vtx[u].dfn <= vtx[v].dfn && vtx[v].dfn <= vtx[u].dfn + vtx[u].sz - 1; }

int get_vertex(int u, int v) { // get the closest vertex from u to v
	int r = u;
	per(bit, 18, 0) if (vtx[vtx[r].fa[bit]].dep >= vtx[v].dep + 1) r = vtx[r].fa[bit];
	return r;
}

inline void work(int u, int v, int x) { // reachable for u, withou reaching v
	if (anc_son(u, v) || anc_son(v, u)) {
		if (vtx[u].dep < vtx[v].dep) return vtx[1].val += x, vtx[v].val -= x, void();
		u = get_vertex(u, v); vtx[u].val += x;
		return ;
	}
	vtx[1].val += x, vtx[v].val -= x;
}

ll ans[MAXN];
void calc_ans(int u) {
	vtx[u].val += vtx[vtx[u].fa[0]].val;
	ans[u] = vtx[u].val;
	for (int v : E[u]) if (v != vtx[u].fa[0]) calc_ans(v);
}

int main() {
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif
	IO::read(n);
	rep(i, 1, n - 1) {
		int u, v; IO::read(u), IO::read(v);
		Edge[i] = make_pair(u, v);
		E[u].push_back(v), E[v].push_back(u);
	}
	IO::read(q);
	dfs(1);
	rep(i, 1, q) {
		int t, e, x, u, v;
		IO::read(t), IO::read(e), IO::read(x);
		u = Edge[e].first, v = Edge[e].second;
		if (t == 2) swap(u, v);
		work(u, v, x);
	}
	calc_ans(1);
	rep(i, 1, n) IO::write(ans[i], '\n');
	return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, C;
    cin >> n >> C;
    map<int, vector<int>> op;
    map<int, vector<int>> cl;
    vector<int> ip;
    for (int i = 0; i < n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        op[a].push_back(c);
        cl[b].push_back(c);
        ip.push_back(a);
        ip.push_back(b);
    }
    sort(ip.begin(), ip.end());
    ip.resize(unique(ip.begin(), ip.end()) - ip.begin());
    int cur = 0;
    int prev = -1;
    int ans = 0;
    for (auto x : ip) {
        ans += (x - prev - 1) * min(C, cur);
        for (auto t : op[x]) cur += t;
        ans += min(C, cur);
        for (auto t : cl[x]) cur -= t;
        prev = x;
    }
    cout << ans << '\n';
}
