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