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

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

ll N;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	double phi=(1+sqrt(5))/2;
	ll A=N/(1+phi),B=N-A;
	
	for(i=-3000;i<=3000;i++) {
		ll X=A+i;
		ll Y=B-i;
		if(X<0||Y<0) continue;
		vector<int> V;
		V.push_back(3);
		while(X && V.size()<=130) {
			if(X>=Y) {
				V.push_back(3);
				X-=Y;
			}
			else if(X<Y) {
				V.push_back(4);
				Y-=X;
			}
		}
		if(Y+V.size()>130) continue;
		FOR(i,Y) V.push_back(2);
		reverse(ALL(V));
		cout<<V.size()<<endl;
		FORR(v,V) cout<<v<<endl;
		return;
	}
	assert(0);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
vector<pair<int, int>> E[200001];
int A[200001], B[200001];
ll zentai = 0;
ll kari = 0;
ll q[200001];
ll kotae[200001];

void dfs(int a, int mae) {

	kotae[a] = kari;
	for (auto p : E[a]) {
		int to = p.first;
		int e = p.second;
		if (mae == to) continue;

		if (B[e] == a) {
			kari += q[e];
			dfs(to, a);
			kari -= q[e];
		}
		else {
			zentai += q[e];
			kari -= q[e];
			dfs(to, a);
			kari += q[e];
		}

	}

}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	cin >> N;
	rep1(i, N - 1) {
		int a, b;
		cin >> a >> b;
		A[i] = a;
		B[i] = b;
		E[a].pb(mp(b, i));
		E[b].pb(mp(a, i));
	}
	int Q;
	cin >> Q;
	rep(i, Q) {
		int t, e, x;
		cin >> t >> e >> x;
		if (t == 2) {
			zentai += x;
			q[e] += -x;
		}
		else q[e] += x;
	}

	dfs(1, 0);

	rep1(i, N) {
		co(zentai + kotae[i]);
	}

	Would you please return 0;
}