#pragma comment(linker, "/STACK:102400000,102400000") #include <iostream> #include<stdio.h> #include<string.h> #include<vector> #include<algorithm> #include<cmath> #include<map> #include<queue> #define lson l,m,rt<<1 #define rson m+1,r,rt<<1 | 1 #define lowbit(x) x&(-x) using namespace std; const int N=1e5+10; long long INF=-1e15; int T,n,m,k; int ans; const int MOD=1e9+7; int f[10],on[10],off[10]; int tot; void init(){ memset(f,0,sizeof f); memset(on,0,sizeof on); memset(off,0,sizeof off); tot=0; } struct Edge{ int u,v; }edge[64]; void dfs(int n){ if(n==tot){ ans++; return; } int u=edge[n].u,v=edge[n].v; if(on[u]>f[u]) return; if(off[u]>f[u]) return; if(on[v]>f[v]) return; if(off[v]>f[v]) return; if(on[u]<f[u] && on[v]<f[v]){ on[u]++;on[v]++; dfs(n+1); on[u]--;on[v]--; } if(off[u]<f[u] && off[v]<f[v]){ off[u]++;off[v]++; dfs(n+1); off[u]--;off[v]--; } } int main() { #ifndef ONLINE_JUDGE freopen("aaa","r",stdin); #endif int T; scanf("%d",&T); while(T--){ scanf("%d%d",&n,&m); init(); int u,v; for(int i=0;i<m;i++){ scanf("%d%d",&u,&v); f[u]++;f[v]++; edge[tot++]=Edge{u,v}; } for(int i=1;i<=n;i++) f[i]/=2; ans=0; dfs(0); printf("%d\n",ans); } return 0; }