#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int n,l[N],r[N],k[N],d[N];
int head[N],nxt[N],to[N],tot;
bool vis[N];
void add(int u,int v){
	to[++tot]=v;
	nxt[tot]=head[u];
	head[u]=tot;
}
int tre[2*N];
void build(int rt,int l,int r) {
	if (l==r) tre[rt]=d[l];
	else{
		int mid=(l+r)/2;
		build(rt*2,l,mid);
		build(rt*2+1,mid+1,r);
		tre[rt]=min(tre[rt*2],tre[rt*2+1]);
	}
}
int g(int rt,int l,int r,int xl,int xr){
	if (xl<=l&&xr>=r) return tre[rt];
	if (xl>r||xr<l) return 10000000;
	int mid=(l+r)/2;
	return min(g(rt*2,l,mid,xl,xr),g(rt*2+1,mid+1,r,xl,xr));
}
int main(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	scanf("%d",&n);
	int u,v,q;
	for (int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	scanf("%d",&q);
	bool flag=false;
	for (int i=1;i<=q;i++){
		scanf("%d%d%d",&l[i],&r[i],&k[i]);
		if (k[i]!=r[i]-l[i]+1) flag=true;
	}
	int j=1;
	for (int i=1;i<=n;i++){
		d[j]=i;
		vis[j]=true;
		int v=to[head[j]];
		if (vis[v]) j=to[nxt[head[j]]];
			else j=v; 
	}
	build(1,1,n);
	for (int i=1;i<=q;i++){
		int ans=0;
		for (int j=l[i];j+k[i]-1<=r[i];j++){
			ans=max(ans,g(1,1,n,j,j+k[i]-1));
		}
		cout<<ans<<endl;
	}
	return 0;
}
