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

int main(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	int n,u,v,q,l,r,k;
	cin>>n;
	for(int i=1;i<n;i++)	cin>>u>>v;
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>l>>r>>k;
		cout<<1<<"\n";
		//orz
	}
	return 0;
}

