#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a; i >-1; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a; i > b; --i)
#define repl(i, a) for (ll i = (ll)0; i < (ll)a; ++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define fi first
#define se second
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll mod_998244353 = 998244353;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

//using lll=boost::multiprecision::cpp_int;
//using Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<128>>;//仮数部が1024桁
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll mypow(ll x, ll n, const ll &p = -1)
{ //x^nをmodで割った余り

	if (p != -1)
	{
		x =(x%p+p)%p;
	}
	ll ret = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			if (p != -1)
				ret = (ret * x) % p;
			else
				ret *= x;
		}
		if (p != -1)
			x = (x * x) % p;
		else
			x *= x;
		n >>= 1;
	}
	return ret;
}

using namespace std;
//using namespace atcoder;

void solve()
{
	ll n,k;
	cin>>n>>k;

	vector<ll>S(n*3+1);
	S[0]=1;
	S[n]=-3;
	S[n*2]=3;
	S[n*3]=-1;
	rep(i,3){
		rep(j,n*3){
			S[j+1]+=S[j];
		}
	}
	for(ll sum=3;sum<=n*3;++sum){
		
		ll val=S[sum-3];
		if(k-val<=0){
			//和がsum
			for(ll i=1;i<=n;++i){
				ll sub=max<ll>(0,min(n,sum-i-1)-max(1LL,sum-i-n)+1);
				if(k-sub<=0){
					//1個目がi,残りの和はsum-i
					for(ll j=max<ll>(1,sum-i-n);j<=n;++j){
						--k;
						if(!k){
							cout<<i<<" "<<j<<" "<<sum-i-j<<"\n";
							return;
						}
					}
				}
				k-=sub;
			}
		}
		k-=val;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



#include <bits/stdc++.h>
#define M 1000000007
#define pii 3.14159265359 
#define pb push_back
#define pob pop_back 
#define forr(i,n) for(i=0;i<n;i++)
#define fors(i,j,n) for(i=j;i<n;i++)
#define pi pair<int,int>
#define ff first
#define ss second
#define tcase 0
#define all(v) v.begin(),v.end()
typedef long long int ll;
using namespace std;
#define sc(n) scanf("%lld",&n)
#define scn(n) scanf("%d",&n)
#define prt(n) printf("%lld ",n)
#define prtln(n) printf("%lld\n",n)

vector<pi> edges;
vector<vector<int>> v;
vector<int> prt;
vector<ll> val;
vector<ll> ans;

void assign_prt(int node,int p) {
	prt[node] = p;
	for(auto x : v[node]) {
		if(x==prt[node]) continue;
		assign_prt(x,node);
	}
}	

void find_ans(int node,int p,ll c) {
	ans[node] += c + val[node];
	for(auto x : v[node]) {
		if(x==prt[node]) continue;
		find_ans(x,node,c+val[node]);
	}
}

void solve() {
    int n,i;
    scn(n);

    v.clear(); edges.clear(); prt.clear(); val.clear(); ans.clear();
    v.resize(n+1); prt.resize(n+1); val.resize(n+1,0ll);
    forr(i,n-1) {
    	int a,b;
    	scn(a); scn(b);
    	edges.pb({a,b});
    	v[a].pb(b); v[b].pb(a);
    }

    assign_prt(1,-1);

    int q;
    scn(q);

    forr(i,q) {
    	int a,b; ll value;
    	scn(a); scn(b); sc(value);

 		int v1,v2;
    	if(a==1) {
    		v1 = edges[b-1].ff;
    		v2 = edges[b-1].ss;
    	}
    	else {
    		v1 = edges[b-1].ss;
    		v2 = edges[b-1].ff;
    	}

    	if(v2==prt[v1]) {
    		val[v1] += value;
    	}
    	else {
    		val[1] += value;
    		val[v2] += -value;
    	}
    }

    ans.resize(n+1,0ll);
    find_ans(1,-1,0);

    fors(i,1,n+1) prtln(ans[i]);
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int t = 1; 
    if(tcase) scn(t); 
    while(t--) solve();
    return 0;
}
