#include<bits/stdc++.h>
using namespace std;
const int N=15;
typedef long long LL;
int degree[N];
LL C[N][N];
LL det(LL a[][N],int n){
LL ret=1;
for(int i=1; i<n; i++){
for(int j=i+1; j<n; j++)
while(a[j][i]){
LL t=a[i][i]/a[j][i];
for(int k=i; k<n; k++)
a[i][k]=(a[i][k]-a[j][k]*t);
for(int k=i; k<n; k++)
swap(a[i][k],a[j][k]);
ret=-ret;
}
if(a[i][i]==0)return 0;
ret=ret*a[i][i];
}
if(ret<0)ret=-ret;
return ret;
}
int main(){
int tcase;cin>>tcase;
while(tcase--){
memset(degree,0,sizeof(degree));
memset(C,0,sizeof(C));
int n,m,u,v;
scanf("%d%d",&n,&m);
while(m--){
scanf("%d%d