#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;

int n,q;
vector<vector<int> > e;
int fa[500005];
int dep[500005];
//love Eunice 
void dfs(int x)
{
	dep[x] = dep[fa[x]] + 1;
	if(e[x].size() == 0)
		return;
	for(int i = 1;i <= e[x].size();i++)
	{
		if(e[x][i] == fa[x])
			continue;
		fa[e[x][i]] = x;
		dfs(e[x][i]);
	}
	return;
}

int LCA(int x,int y)
{
	if(dep[x] > dep[y])
		swap(x,y);
	while(dep[x] < dep[y])
	{
		y = fa[y];
	}
	while(x != y)
	{
		x = fa[x],y = fa[y];
	}
	return x;
}

int main()
{
	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);
		//e[u].push_back(v);
		//e[v].push_back(u);
	}
	fa[1] = 0,dep[0] = 0;
	//dfs(1);
	scanf("%d",&q);
	for(int i = 1;i <= q;i++)
	{
		int l,r,k;
		scanf("%d %d %d",&l,&r,&k);
		printf("%d\n",1);
	}
	return 0;
} 
