#include<bits/stdc++.h>
using namespace std;
pair<int,int> dep[500005];
int G[500005][5];
int main(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	int n,q,i,j,k,m,t,u,v;
	scanf("%d",&n);
	for(i=1;i<n;i++) {
		scanf("%d%d",&u,&v);
	}
	scanf("%d",&q);
	for(i=1;i<=q;i++) {
		int l,r,k;
		scanf("%d%d%d",&l,&r,&k);
		printf("1\n"); 
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
