#include<iostream>
#include<vector>
#include<fstream>
using namespace std;
const int maxn=500005;
int n,q,s;
vector<int>G[maxn];
int sum[maxn];
bool vis[maxn];
int main(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	cin >> n;
	int u,v;
	for(int i=1;i<=n-1;i++){
		scanf("%d%d",&u,&v);
		sum[u]++;sum[v]++;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=1;i<=n;i++){
		if(sum[i]==1){
			s=i;break;
		}
	}
	int t=s;
	while(!vis[t]){
		vis[t]=1;
		sum[G[t][0]]=sum[t]+1;
		t=G[t][0];
	}
	cin >> q;
	int l,r,k;
	for(int i=1;i<=q;i++){
		scanf("%d%d%d",&l,&r,&k);
		cout << min(sum[l],sum[r])+k-1;
	}
	return 0;
}
