#include<bits/stdc++.h>
#define pb push_back
#define is insert
#define fi first
#define se second
#define mkp make_pair
#define INF INT_MAX
#define mem(a,b) memset(a,b,sizeof a)
#define cpy(a,b) memcpy(a,b,sizeof b)
#define mathmod(a,m) (((a)%(m)+(m))%(m))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int N=5e5+5;
int n,q,dep[N];
vector<int> G[N]; 
void dfs(int u,int fa){
	dep[u]=dep[fa]+1;
	for(int v:G[u]){
		if(v==fa) continue;
		dfs(v);
	}
}
int main(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1,u,v;i<n;i++) cin>>u>>v,G[u].pb(v),G[v].pb(u);
	dfs(1,0);
	cin>>q;
	for(int i=1,l,r,k;i<=q;i++){
		cin>>l>>r>>k;
		cout<<r-k+1<<"\n";
	}
	cout<<flush;
	return 0;
}


