#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef long long LL; typedef double db; #define _Zero(a) memset(a,0,sizeof(a)) #define _Neg1(a) memset(a,-1,sizeof(a)) #define _Inf(a) memset(a,0x3f,sizeof(a)) #define _NegInf(a) memset(a,0xcf,sizeof(a)) #define _Rep(i,a,b) for(int (i)=(a);(i)<=(b);i++) #define _Dep(i,a,b) for(int (i)=(a);(i)>=(b);i--) #define _Out(a) cerr<<(#a)<<" = "<<(a)<void test(T x,Args...args){cerr<>1)%MOD : qpow(a*a%MOD,b>>1))%MOD :1; } ll qpow(ll a, ll b, ll c) {return b?((b&1)?a*qpow(a*a%c,b>>1)%c : qpow(a*a%c,b>>1)) % c: 1; } ll gcd(ll a, ll b){return b?gcd(b,a% b): a; } int sign(db x) { return x<-EPS ? -1: x>EPS; } int dbcmp(db l, db r) { return sign(l - r); } const ll mod=1e9+7; const int N=1e6+10; ll fac[N],inv_fac[N]; long long jc[1000000],ny[1000000]; //jc[i]表示i的阶乘 ny[i]表示i的阶乘的逆元 long long C(long long n,long long m) //求组合数 { swap(n,m); if(n==0||n==m)return 1; return jc[m]*ny[n]%mod*ny[m-n]%mod; //m的阶乘*n阶乘的逆元*(m-n)阶乘的逆元 } int cnt[MAXN]; ll dp[3]; int main() { int T; jc[1]=1; ny[1]=1; for(int i=2;i<400050;i++) //预处理jc数组和ny数组 { jc[i]=jc[i-1]*i%mod; ny[i]=qpow(jc[i],mod-2); } // printf("%lld\n",C(5,2)); scanf("%d",&T); while(T--) { int n; scanf("%d",&n); for(int i=1;i<=n*2;i++)cnt[i]=0; for(int i=1;i<=n*2;i++) { int x; scanf("%d",&x); cnt[x]++; } int la=0;dp[0]=1;dp[1]=dp[2]=0; for(int i=1;i<=2*n;i++) { ll tmp[3]={0}; // printf("%d:%lld %lld ",i,dp[1],dp[2]);printf("%lld\n",dp[0]);printf("%d\n",cnt[i]); if(cnt[i]==0)continue; if(cnt[i]%2) { tmp[0]=(tmp[0]+(dp[1]+dp[2])*C(cnt[i],cnt[i]/2+1))%mod; tmp[1]=(tmp[1]+dp[0]*C(cnt[i],cnt[i]/2+1))%mod; tmp[2]=(tmp[2]+dp[0]*C(cnt[i],cnt[i]/2+1))%mod; } else { tmp[0]=(tmp[0]+dp[0]*C(cnt[i],cnt[i]/2))%mod; tmp[1]=(tmp[1]+dp[1]*C(cnt[i],cnt[i]/2))%mod; tmp[2]=(tmp[2]+dp[2]*C(cnt[i],cnt[i]/2))%mod; tmp[1]=(tmp[1]+dp[2]*C(cnt[i],cnt[i]/2+1))%mod; tmp[2]=(tmp[2]+dp[1]*C(cnt[i],cnt[i]/2+1))%mod; } dp[0]=tmp[0];dp[1]=tmp[1];dp[2]=tmp[2]; } // printf("%lld %lld ",dp[1],dp[2]); printf("%lld\n",dp[0]); } } /* */