#include<bits/stdc++.h>
using namespace std;
long long c,T,n,m;
struct Edge
{
	long long nxt,v;
}edge[200010];
long long head[100010],cnt;
long long answer=0;
void add(long long u,long long v)
{
	cnt++;
	edge[cnt].nxt=head[u];
	edge[cnt].v=v;
	head[u]=cnt;
	return;
}
bool cmp[100010];
void init()
{
	for(int i=1;i<=n;i++)cmp[i]=0;
	return;
}
void solve(long long x,long long y)
{
	bool kl=0;
	for(int i=head[x];i;i=edge[i].nxt)
	{
		if(cmp[edge[i].v]==0)
		{
			cmp[edge[i].v]=0;
			kl=1;
			solve(x,edge[i].v);
		 } 
	} 
	for(int i=head[y];i;i=edge[i].nxt)
	{
		if(cmp[edge[i].v]==0)
		{
			cmp[edge[i].v]=0;
			kl=1;
			solve(y,edge[i].v);
		}
	}
	if(kl==0)answer++;
	return;
}
int main()
{
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	scanf("%lld",&c);
	scanf("%lld",&T);
	while(T--)
	{
		scanf("%lld%lld",&n,&m);
		for(int i=1;i<n;i++)
		{
			long long x,y;
			scanf("%lld%lld",&x,&y);
			add(x,y);
			add(y,x);
		}	
		for(int i=1;i<=m;i++)
		{
			long long x;
			answer=0;
			init();
			scanf("%lld",&x);
			cmp[edge[x].nxt]=1;
			cmp[edge[x].v]=1;
			solve(edge[x].nxt,edge[x].v);
			printf("%lld\n",answer);
		}
	 } 
	return 0;
}
