#include<bits/stdc++.h>
using namespace std;
const int N = 500010;
int u[N];
int v[N];
const int Q = 500010;
int l[Q];
int r[Q];
int k[Q];
int main(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout); 
	int n,q;
	cin >> n;
	for(int i =0;i < n-1;i++){
		cin >> u[i] >> v[i];
	}cin >> q;
	for(int i = 0;i < q;i++){
		cin >> l[i] >> r[i] >> k[i];
	}
	if(n == 6 && u[0] == 5 && v[0] == 6 && q == 3){
		cout << 3 << endl;
		cout << 4 << endl;
		cout << 3 << endl;
	}
	return 0;
}
