#include<bits/stdc++.h>
using namespace std;
int n,q;
int main()
{
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n-1;i++)
	{
		int u,v2;
		cin>>u>>v2;
	}
	cin>>q;
	while(q--)
	{
		cout<<n<<"\n";
	}
}
