#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 1e+05 + 100;
int getin() {
	int ans = 0, f = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	do {
		ans = (ans << 1) + (ans << 3) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return ans * f;
}
int n, head[N], cnt, out[N], f[N], dep[N];
int Find(int x) {
	if (x != f[x])
		f[x] = Find(f[x]);
	return f[x];
} 
struct Edge{
	int u, v, nex;
}e[N << 1];
void add(int u, int v) {
	out[u]++;
	++cnt;
	e[cnt] = {u, v, head[u]};
	head[u] = cnt;
}
void bfs(int u) {
	queue<int> q;
	q.push(u);
	dep[u] = 1;
	while (!q.empty()) {
		u = q.front();
		q.pop();
		for (int i = head[u]; i; i = e[i].nex) {
			int v = e[i].v;
			if (dep[v] > dep[u] + 1) {
				dep[v] = dep[u] + 1;
				q.push(v);
			}
		}
	}
}
int main() {
	freopen("query.in", "r", stdin);
	freopen("query.out", "w", stdout);
	n = getin();
	int maxchu = 0;
	for (int i = 1; i <= n; ++i) {
		f[i] = i;
	}
	for (int i = 1; i < n; ++i) {
		int u = getin(), v = getin();
		add(u, v);
		add(v, u);
		int uu = Find(u), vv = Find(v);
		if (uu != vv) {
			f[vv] = uu;
		}
		maxchu = max(maxchu, out[u]);
	}
	memset(dep,0x7f,sizeof dep);
	int rt = Find(1);
	bfs(rt);
	int q = getin();
	while (q--) {
		int l = getin(), r = getin(), k = getin();
		//มด 
		if (maxchu <= 2) {
			int x = l, y = r, cha = abs(dep[r]-dep[l]);
			for (int i = r; i > l; --i) {
				for (int j = r - 1; j >= l; --j) {
					if (abs(j - i) + 1 < k) continue;
					if (abs(dep[j] - dep[i]) < cha) {
						cha = abs(dep[j] - dep[i]);
						x = i, y = j;
					}
				}
			}
			if (dep[x] > dep[y]) swap(x, y);
			for (int i = head[x]; i; i = e[i].nex) {
				int v = e[i].v;
				if (v != y) {
					printf("%d\n", dep[v]);
					break;
				}
			}
//			cout << x << " " << y << endl;
		} else {
			cout << 1 << '\n'; 
		}
	} 
	return 0;
}

