#include<bits/stdc++.h>
using namespace std;
#define lp (p<<1)
#define rp (p<<1)+1
const int mod=1e9+7;
const int maxn=5e5;
int n,q,cnt=0,dep[maxn+10];
vector<int> edge[maxn+3]; 
int tree[4*maxn+20];
map<pair<int,int>,int> mp;
void dfs(int x,int fa){
	dep[x]=dep[fa]+1;
	if(edge[x].size()==0)return;
	for(int i:edge[x]){
		dfs(i,x);
	} 
	return;
}

int lca(int l,int r){
	bool vis[maxn+10];
	while(l!=1||r!=1){
		if(l!=1&&edge[l].size()>0)
		for(int i:edge[l])if(dep[i]<dep[l]){
			l=i;break;
		}
		vis[l]=true;
		if(r!=1&&edge[r].size()>0)
		for(int i:edge[r])if(dep[i]<dep[r]){
			r=i;break;
		}
		if(vis[r])return r;
	}
	return 1;
}

void solve(){
	cin >> n;
	for(int i=1;i<n;i++){
		int x,y;
		cin >> x >> y;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	dep[0]=0;
	dfs(1,0);
	
	cin >> q;
	while(q--){
		int l,r,k,ans=-0x3f;
		cin >> l >> r >> k;
		for(int i=l;i<=r-k+1;i++){
			ans=max(lca(i,i+k),ans);
		}
		cout<<ans<<endl;
	}
	return ;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	int t;
	cin >> t >> t;
//	t=4;
	while(t--){
		solve();
	}
	return 0;
}
