#include<bits/stdc++.h>
using namespace std;
int n,u,v,q,l,r,k;
int main()
{
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	scanf("%d",&n);
	for(register int i=1;i<n;++i) 
	{
		scanf("%d%d",&u,&v);
	}
	scanf("%d",&q);
	for(register int i=1;i<=q;++i)
	{
		scanf("%d%d%d",&l,&r,&k);
		cout<<1<<endl;
	}
	return 0;
}
