#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int> g[500005];
int d[500005],rt,q,n,ans;
void dfs(int u,int fa){
	for (int v:g[u]){
		if (v!=fa){
			d[v]=d[u]+1;
			dfs(v,u);
		}
	}
}
signed main()
{
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);	
	cin>>n;
	for (int i=1;i<=n;i++){
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,1);
	cin>>q;
	while (q--){
		cout<<1<<endl;
	}
	//Happy AFO!
}

