#include<bits/stdc++.h>
using namespace std;
const int N=505;
int n; 
int main(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout); 
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	cin>>n;
	for(int i=1,u,v;i<n;i++)
		cin>>u>>v; 
	int q,l,r,k,ans;
	cin>>q;
	while(q--){
		cin>>l>>r>>k;
		ans=1;
		cout<<ans<<"\n";
	}
	return 0;
}
