#include <stdio.h>
#include <algorithm>
using namespace std;
#define MAXN 500005
#define MOD 1000000007
int n, q;
int head[MAXN], nxt[MAXN << 2], to[MAXN << 2], tot, dep[MAXN];
void add(int u, int v){
	to[++tot] = v;
	nxt[tot] = head[u];
	head[u] = tot;
}
void dfs(int u, int f){
	dep[u] = dep[f] + 1;
	for(int i = head[u]; i; i = nxt[i]){
		int v = to[i];
		if(v == f)
			continue;
		dfs(v, u);
	}
}
int main(void){
	freopen("query.in", "r", stdin);
	freopen("query.out", "w", stdout);
	scanf("%d", &n);
	for(int i = 1; i < n; i++){
		int u, v;
		scanf("%d%d", &u, &v);
		add(u, v), add(v, u);
	}
	dep[0] = 0;
	dfs(1, 0);
	scanf("%d", &q);
	
	while(q--){
		int l, r, k;
		scanf("%d%d%d", &l, &r, &k);
		printf("%d\n", max(dep[l], dep[r]) - k + 1);
	}
	
	return 0;
}

/*
6
5 6
6 1
6 2
2 3
2 4
3
2 5 2
1 4 1
1 6 3

*/
