#include #include #include using namespace std; typedef long long ll; const int mod=1000000007; const int M=200010; int cas,n,a[M],A[M]; ll jie[M],inv[M]; ll C(int n,int m){ return jie[n]*inv[m]%mod*inv[n-m]%mod; } int main(){ jie[0]=1;inv[0]=inv[1]=1; for (int i=1;i<=200000;i++)jie[i]=jie[i-1]*i%mod; for (int i=2;i<=200000;i++)inv[i]=inv[mod%i]*(mod-mod/i)%mod; for (int i=2;i<=200000;i++)inv[i]=inv[i]*inv[i-1]%mod; scanf("%d",&cas); while (cas--){ scanf("%d",&n); int flag=0,cnt=0; ll ans=1; for (int i=1;i<=2*n;i++)scanf("%d",&a[i]); int tmp=1; for (int i=2;i<=2*n;i++){ if (a[i]==a[i-1])tmp++; else{ A[++cnt]=tmp; tmp=1; } } A[++cnt]=tmp; for (int i=1;i<=cnt;i++){ if (!flag){ if (A[i]%2==1)ans=ans*2*C(A[i],A[i]/2)%mod; else ans=ans*C(A[i],A[i]/2)%mod; }else{ if (A[i]%2==1)ans=ans*C(A[i],A[i]/2)%mod; else ans=ans*(C(A[i],A[i]/2)+C(A[i],A[i]/2-1))%mod; } if (A[i]%2==1)flag^=1; } printf("%I64d\n",ans); } }