#include<bits/stdc++.h>
using namespace std;
#define N 1000010
int a[N][10];
int q[N];
int h[N];
int h1;
int v[N];
int o[N];
void bianli(int x)
{
	h1++;
	v[x]=1;
	h[x]=h1;
	o[h1]=x;
	if(q[x]>=1)
	  {
	  	int t0=a[x][0];
	  	int t1=a[x][1];
	  	if(v[t0]==0)
	  	  bianli(t0);
		if(v[t1]==0)
		  bianli(t1); 
	  }
	else
	  {
	  	int t=a[x][0];
	  	if(v[t]==0)
	  	  bianli(t);
	  }
}
int main()
{
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	  {
	  	int u,v;
	  	cin>>u>>v;
	  	a[u][q[u]]=v;
	  	a[v][q[v]]=u;
	  	q[u]++;
	  	q[v]++;
	  }
	bianli(1);
	int Q;
	cin>>Q;
	while(Q--)
	  {
	  	int l,r,k;
	  	cin>>l>>r>>k;
	  	int x=0x3f3f3f3f,y=0;
	  	for(int i=l;i<=r;i++)
	  	  {
	  	  	if(h[i]<x)
	  	  	  {
	  	  	  	x=h[i];
	  	  	  	y=i;
				  }
			}
	  	cout<<y<<endl;
	  }
 } 
