#include #define fi first #define se second #define pb push_back #define SZ(x) ((int)x.size()) #define L(i,u) for (register int i=head[u]; i; i=nxt[i]) #define rep(i,a,b) for (register int i=(a); i<=(b); i++) #define per(i,a,b) for (register int i=(a); i>=(b); i--) using namespace std; typedef long long ll; typedef unsigned int ui; typedef pair Pii; typedef vector Vi; template inline void read(T &x){ x=0; char c=getchar(); int f=1; while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();} while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f; } template inline void umin(T &x, T y){x=x inline void umax(T &x, T y){x=x>y?x:y;} inline ui R() { static ui seed=416; return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13; } const int N = 233333,mo=1e9+7; int cntp[N],cntm[N],qzm[N],mi[N]; int n,a[N],cnt[N],fac[N],ifac[N]; int power(int a, int n){ int res=1; while(n){ if(n&1)res=1LL*res*a%mo; a=1LL*a*a%mo;n>>=1; } return res; } void init(int n){ mi[0]=1;rep(i,1,n)mi[i]=2*mi[i-1]%mo; fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo; ifac[n]=power(fac[n],mo-2); per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo; } int A(int n, int m){return m>=0&&m<=n?1LL*fac[n]*ifac[n-m]%mo:0;} int C(int n, int m){return m>=0&&m<=n?1LL*fac[n]*ifac[n-m]%mo*ifac[m]%mo:0;} int main() { int T;read(T);init(N-1); while(T--){ read(n);rep(i,0,2*n)cnt[i]=cntp[i]=cntm[i]=0; rep(i,1,n*2)read(a[i]),cnt[a[i]]++; int res=1,cur=0; rep(i,1,n*2)if(cnt[i]){ if(cur==1&&cnt[i]%2==1){ res=1LL*res*C(cnt[i],cnt[i]/2)%mo; } else if(cur==1&&cnt[i]%2==0){ res=1LL*res*(C(cnt[i],cnt[i]/2)+C(cnt[i],cnt[i]/2+1))%mo; } else if(cnt[i]%2==1){ res=1LL*res*2*C(cnt[i],cnt[i]/2)%mo; } else res=1LL*res*C(cnt[i],cnt[i]/2)%mo; cur+=cnt[i];cur%=2; } printf("%d\n",res); } return 0; }