#include<bits/stdc++.h>
#define ll long long 
#define endl putchar('\n')
#define ygkg putchar(' ')
const ll inf=10000000000000000;
const ll mod=1000000007;
namespace io
{
	template<typename LX>
	void in(LX &ygs)
	{
		ygs=0;bool pdfh=0;char ch=getchar();
		while(!isdigit(ch)) pdfh=ch=='-',ch=getchar();
		do{ygs=(ygs<<3)+(ygs<<1)+(ch^48),ch=getchar();}while(isdigit(ch));
		if(pdfh) ygs=-ygs;
	}
	template<typename LX>
	void _out(LX ygs){if(ygs) _out(ygs/10),putchar((ygs%10)^48);return;}
	template<typename LX>
	void out(LX ygs){_out((ygs>0)?(ygs):(ygs?(putchar('-'),-ygs):(putchar('0'),0)));return;}
}
using namespace io;
using namespace std;
ll n,a,b,q;
int main()
{
	freopen("query.in","r",stdin);
	freopen("query.out","w",stdout);
	in(n);
	for(ll i=1;i<n;++i) in(a),in(b);
	in(q);
	for(ll i=1;i<=q;++i) out(1),endl;
	return 0;
}
