#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int c,T,n,k; 
struct qp{
	int u,v;
}b[N];
bool ok[N];
int jc[N];
int main(){
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	cin>>c>>T;
	while(T--){
		cin>>n>>k;
		for(int i=1;i<n;i++)
			cin>>b[i].u>>b[i].v;
		memset(ok,0,sizeof(ok));
		for(int i=1,tmp;i<=k;i++)
			cin>>tmp,ok[tmp]=1;
		if(c==18){
			cout<<"1\n";
			continue;
		}
	}
	
	return 0;
} 
