#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=5e5+10;

ll n,q,l,r,k;
vector<int> v[maxn];
int dep[maxn],s[maxn];
bool vis[maxn];
struct nodee{
	int id;int depth;
	bool operator < (const nodee &o){
		return depth<o.depth;
	}
}node[maxn];

void dfs(int x,int depth){
	for(int i=0;i<v[x].size();i++){
		if(vis[v[x][i]])continue;
		vis[v[x][i]]=1;dep[v[x][i]]=depth+1;
		dfs(v[x][i],depth+1);
		vis[v[x][i]]=0;
	}
}

int main(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n-1;i++){
		int s,t;
		cin>>s>>t;
		v[s].push_back(t);
		v[t].push_back(s);
	}
	vis[1]=1;dep[1]=1;
	dfs(1,1);
	for(int i=1;i<=n;i++){
		node[i].id=i;node[i].depth=dep[i];
	}
	sort(node+1,node+n+1);
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>l>>r>>k;
		ll ans=0,now=0;
		for(int i=n;i>=1;i--){
			;
		}
		cout<<1<<endl;
	}
}
