//Nice P3, enjoyed #include using namespace std; inline int read() { char c=getchar(); int x=0; while(!isdigit(c)) c=getchar(); while(isdigit(c)) x=x*10+(c&15),c=getchar(); return x; } const int p=1e9+7,half=(p+1)>>1; inline int qp(int x,int y) { int r=1; for(int i=x; y; y>>=1,i=1ll*i*i%p) if(y&1) r=1ll*r*i%p; return r; } vector> e[1<<17]; int fac[1<<17],ifac[1<<17]; int u[1<<17],v[1<<17],a[1<<17]; int f[1<<17],g[1<<17],h[1<<17],w[1<<17]; inline void dfs(int x,int fa) { int sz=e[x].size(); f[x]=g[x]=1,w[x]=h[x]=0; for(auto i:e[x]) { int y=i.first; if(y==fa) continue; dfs(y,x),f[x]=1ll*f[x]*f[y]%p,g[x]=1ll*g[x]*g[y]%p; } int sum=0; for(auto i:e[x]) { int y=i.first,id=i.second; if(y==fa) continue; if(a[id]) w[y]=1; h[x]=(h[x]+1ll*h[y]*fac[sz-1]%p*g[y]%p*f[x])%p, h[x]=(h[x]+1ll*w[y]*(sz-2)%p*fac[sz-2]%p*f[x]%p)%p, h[x]=(h[x]+p-1ll*w[y]*sum%p*fac[sz-2]%p*f[x]%p)%p, sum=(sum+w[y])%p, w[x]=(w[x]+w[y])%p; } f[x]=1ll*f[x]*fac[sz-1]%p,g[x]=1ll*g[x]*ifac[sz-1]%p; if(sz>=2) w[x]=1ll*w[x]*fac[sz-2]%p*ifac[sz-1]%p; return ; } void HappyBirthday() { int n=read(),m=read(); for(int i=1; i=1; --i) ifac[i]=1ll*ifac[i+1]*(i+1)%p; for(int T=read(); T--; HappyBirthday()); return 0; }