#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5,P=1e9+7;
int T,n,m,v,c[M],d[M];
inline void mian(){
	cin>>n>>m>>v;
	for(int i=1;i<=m;i++)cin>>c[i]>>d[i];
	cout<<"0\n";
}
int main(){
	freopen("assign.in","r",stdin);
	freopen("assign.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>T;while(T--)mian();
	return 0;
}
