#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;
const int N = 1e5 + 10, MOD = 1e9 + 7;
bool b[2 * N];
int head[N], vi[2 * N], ne[2 * N], tot, n, k, f[N], d[N];
long long qpow(long long x, int k){
	
}
void addedge(int u, int v){
	ne[++tot] = head[u], vi[tot] = v, head[u] = tot;
}
int main(){
	freopen("traverse.in", "r", stdin);
	freopen("traverse.out", "w", stdout);
	int C, Cases;
	cin >> C >> Cases;
	while(Cases--){
		memset(head, 0, sizeof(head));
		tot = 1;
		cin >> n >> k;
		for(int i = 1, u, v; i < n; i++){
			cin >> u >> v;
			addedge(u, v);
			addedge(v, u);
			d[u]++, d[v]++;
		}
		int x;
		cin >> x;
		cout << n << "\n";
	}
} 
