#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define _rep(i,a,b) for(int i=(a);i>=(b);--i)
#define eb emplace_back
#define MISAKA main
#define FIO(FILE) freopen(FILE".in","r",stdin),freopen(FILE".out","w",stdout)
using namespace std;
bool __st;
inline int read(){
	char c=getchar();int x=0,f=1;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*f;
}
const int N=1e5+10,mod=998244353;
int ID,n,e;vector<int> g[N];
ll qp(ll a,ll b){
	ll r=1;
	for(;b;b>>=1,a=a*a%mod)if(b&1) r=r*a%mod;
	return r;
}
void misaka(){
	rep(i,1,n) g[i].clear();
	n=read(),e=read();
	if(!e){puts("0");return;}
	rep(i,2,n){
		int u=read(),v=read();
		g[u].eb(v);g[v].eb(u);
	}
	rep(i,1,e) read();
	if(ID==18){puts("1");return;}
	
}
bool __ed;
signed MISAKA(){
	FIO("traverse");
	ID=read();int T=read();
	while(T--) misaka();
	return 0;
}

