#include<bits/stdc++.h>
using namespace std;


const int N = 5e5 + 10;

int n, q, cnt;

int dfn[N], sz[N], dep[N], top[N], son[N], f[N], dfn_[N];


vector<int> g[N];

void dfs1(int u, int fa){
	
	dep[u] = dep[fa] + (sz[u] = 1), f[u] = fa;
	
	// cout << u << endl;
	
	for (int v : g[u]){
		if (v == fa) continue;
		dfs1(v, u); sz[u] += sz[v];
		if (sz[v] > sz[son[u]])
			son[u] = v;
	}
}

void dfs2(int u, int t){
	
	// cout << u << endl;
	
	dfn[u] = ++cnt; top[u] = t;
	
	if (son[u]) dfs2(son[u], t);
	
	for (int v : g[u]){
		if (v == f[u] || v == son[u]) continue;
		dfs2(v, v);
	}
	
	
}

struct seg{
#define lc (id << 1)
#define rc (id << 1 | 1)
#define mid ((l + r) >> 1)
	int mx[N << 4], lz[N << 4];

	void init() { memset(mx, 0, sizeof mx); memset(lz, 0, sizeof lz); }

	void pushup(int id){
		mx[id] = max(mx[lc], mx[rc]);
	}
	
	void pushdown(int id, int l, int r){
		int &t = lz[id];
		if (t){
			mx[lc] += t;
			mx[rc] += t;
			lz[lc] += t;
			lz[rc] += t;
			t = 0;
		}
	}
	
	void update(int id, int l, int r, int x, int y, int v){
		if (x <= l && r <= y){
			mx[id] += v, lz[id] += v; return ;
		} pushdown(id, l, r);
		
		if (x <= mid) update(lc, l, mid, x, y, v);
		if (y > mid) update(rc, mid + 1, r, x, y, v);
		pushup(id);
	}
	
	int query(int id, int l, int r, int x, int y){
		if (x <= l && r <= y){
			return mx[id];
		} pushdown(id, l, r);
		int p = 0, q = 0;
		if (x <= mid) p = query(lc, l, mid, x, y);
		if (y > mid) q = query(rc, mid + 1, r, x, y);
		return pushup(id), max(p, q);
	}
	
	int que(int id, int l, int r, int x, int y, int k){
		// if (k == 3) cout << l << " " << r << endl;
		if (l == r) return l;
		int p = mx[lc], q = mx[rc];

		if (y > mid) return que(rc, mid + 1, r, x, y, k);
		else return que(lc, l, mid, x, y, k);


		// if (q == k) return que(rc, mid + 1, r, k);
		// else return que(lc, l, mid, k);
	}
	
}T;

void add(int x, int v){
	if (x < 1 || x > n) return ;
	for (; x;x = f[top[x]])
		T.update(1, 1, n, dfn[top[x]], dfn[x], v);
	// cout << endl;
}

int find(int x, int v){
	// if (x < 1 || x > n) 
	for (; x; x = f[top[x]]){
		// cout << x << " -> ";
		if (T.query(1, 1, n, dfn[top[x]], dfn[x]) == v){
			// cout << "ok\n";
			return T.que(1, 1, n, dfn[top[x]], dfn[x], v);
		}
	}
	
	// cout << -111111;
	return 1145;
}

signed main(){
 	
 	 freopen("query.in", "r", stdin);
 	 freopen("query.out", "w", stdout);
 	
 	cin.tie(0) -> sync_with_stdio(0);
 	
 	cin >> n;
 	
 	for (int i = 1, u, v; i < n; i++){
 		cin >> u >> v;
 		g[u].push_back(v);
 		g[v].push_back(u);
 	}
 	
 	// cout << -1;
 	
 	dfs1(1, 0), dfs2(1, 1);
 	
 	// for (int i = 1; i <= n; i++)
 		// cout << dfn[i] << " \n"[i == n];
//  	
 	// for (int i = 1; i <= n; i++)
 		// cout << f[i] << " \n"[i == n];
 	
 	// cout << -1111 << endl;
 	
 	for (int i = 1; i <= n; i++){
 		dfn_[i] = i;
 	}
 	
 	sort(dfn_ + 1, dfn_ + 1 + n, [](int a, int b){
 		return dfn[a] < dfn[b];
 	});
 	
 	cin >> q;
 	
 	for (int l, r, k; q--; ){

 		cin >> l >> r >> k;

		int ans = 0; T.init();

 		for (int i = l; i <= l + k - 1; i++){
 			add(i, 1);
 		}
 		
 		for (int L = l, R = L + k - 1; R <= r; ){
 			ans = max(ans, find(L, k));
 			// cout << q + 100000 << endl;
 			add(L, -1), add(R + 1, 1); L++, R++;
 		}
 		
 		// cout << q + 100000 << endl;
 		
 		cout << ans << endl;
 		
 		// cout << dfn_[ans] << endl;
 		
 	}
 	
 	
 	return 0;
 }
