#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9 + 7;
struct edge{
	int u, int v;
}qp[100100];
int T, n, k, e[100100], c;

void solve18()
{
	printf("1\n");
	return;
}

int main()
{
	freopen("traverse.in","r",stdin);
	freopen("traverse.out","w",stdout);
	scanf("%d%d", &c, &T);
	if(c == 18)
	{
		while(T--)
		{
			solve18();
		}
	}
	else
	{
		while(T--)
		{
			scanf("%d%d", &n ,&k);
			for(int i = 1; i < n; ++i)
			{
				scanf("%d%d", &qp[i].u, &qp[i].v);
			}
			for(int i = 1; i <= k; ++i)
			{
				scanf("%d", e+i);
			}
			
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
