#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1000010;
int n,to[N],he[N],ne[N],cnt,ru[N],chu[N],de[N];
int ans,ro,q;
bool v[N];
void add(int x,int y){
	to[++cnt]=y;ne[cnt]=he[x];he[x]=cnt;
}
void dfs(int now,int fa){
	de[now]=de[fa]+1;
	if(v[now])return ;
	v[now]=1;
	for(int i=he[now];i;i=ne[i]){
		int y=to[i];
		if(y==fa)continue;
		dfs(y,now);
	}
}
signed main(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y;cin>>x>>y;
		add(x,y);chu[x]++;ru[y]++;
	}
	for(int i=1;i<=n;i++){
		if(!ru[i]){
			ro=i;//q.push(i);
		}
	}
	dfs(ro,-1);
	cin>>q;
	for(int i=1;i<=q;i++){
		ans=0;
		int l,r,k;cin>>l>>r>>k;
		ans=abs(de[r]-de[l]);
		cout<<ans<<endl;
	}
	return 0;
}
