#include<bits/stdc++.h>
using namespace std;
const int N=1010101;
int T,n,m,a[N],u,v,k,b[N];
vector<int>G[N];
int read(){
	int sum=0;
	char ch;
	ch=getchar();
	while(ch>='0'&&ch<='9'){
		sum=sum*10+(ch-'0');
		ch=getchar();
	}
	return sum;
}
int main(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	n=read();
	for(int i=1;i<n;i++){
		int u,v;
		u=read(),v=read();
		G[u].push_back(v);
		G[v].push_back(u);
	}
	a[1]=1;
	u=1,v=1;
	for(int i=2;i<=n;i++){
		if(G[u][0]!=v)a[G[u][0]]=i,v=u,u=G[u][0];
		else a[G[u][1]]=i,v=u,u=G[u][1];
	}
	k=read();
	for(int i=1;i<=k;i++){
		int l,r,x;
		l=read(),r=read(),x=read();
		for(int j=l;j<=r;j++)b[j-l+1]=a[j];
		sort(b+1,b+r-l+2);
		printf("%lld\n",b[r-l+1-x+1]);
	}
	return 0;
}
