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

int T, n, m, v, c[100100], d[100100];

void ttb()
{
	return;
}

int main()
{
	freopen("assign.in","r",stdin);
	freopen("assign.out","w",stdout);
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d%d",&n,&m,&v);
		bool dj = false;
		for(int j = 1; j <= m; ++j)	
		{
			scanf("%d%d",c+j,d+j);
			if(!dj && d[j] != 1) dj = true;
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
