#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	int n;
	cin>>n;
	int cnt=0;
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		cnt++;
	}
	int flag=0,i=0,ans=0;
	while(flag==0){
		if(ans+pow(2,i)<n) ans+=pow(2,i),i++;
		else flag=1;
	}
	int q;
	cin>>q;
	while(q--) cout<<ans<<endl;
	return 0;
}
