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


int c[100005];
int d[100005];

int main(void) {
#ifndef DEB_MAC
	freopen("assign.in", "r", stdin);
	freopen("assign.out", "w", stdout);
#endif
	int T;
	scanf("%d", &T);
	while(T--) {
		int n, m, v;
		scanf("%d%d%d", &n, &m, &v);
		int tottcA = 0;
		for (int i = 1; i <= m; ++i) {
			scanf("%d%d", &c[i], &d[i]);
			if(c[i] == i) ++tottcA;
		}
		printf("1\n");
	}
	return 0;
}
