#include<bits/stdc++.h>
using namespace std;
#define mod int(1e9+7)
const int N=1e5+10;
int t;
int n,m,v;
struct stu{
	int c,d;
}a[N];
int main()
{
    freopen("assign.in","r",stdin);
    freopen("assign.out","w",stdout);
	cin>>t;
	while(t--){
		scanf("%d%d%d",&n,&m,&v);
		for(int i=1;i<=m;i++) scanf("%d%d",&a[i].c,&a[i].d);
		cout<<mod-1<<endl;
	}
	return 0;
}

