#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>

#define int long long
#define LL long long

using namespace std;
char buf[1 << 21], *p1 = buf, *p2 = buf;
char gc()
{
	if(p1 == p2){p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin);}
	return *(p1) ++;
}
LL read()
{
	LL x = 0, s = 1;
	scanf("%lld", &x); return x;
	char ch = gc();
	while(ch < '0' || ch > '9'){s = ch == '-' ? -1 : s; ch = gc();}
	while('0' <= ch && ch <= '0'){x = (x << 1ll) + (x << 3ll) + (ch ^ 48ll); ch = gc();}
	return x * s;
}

void solve()
{
	int n = read();
	for(int i = 1; i <= n - 1; i ++){read(); read();}
	int q = read();
	for(int i = 1; i <= q; i ++){read(); puts("1");}	
}

signed main()
{
	freopen("query.in", "r", stdin);
	freopen("query.out", "w", stdout); 
	
	int tii = 1;
	for(int z = 1; z <= tii; z ++){solve();}
}

