#include using namespace std; long long readInt(long long l,long long r,char endd){ long long x=0; int cnt=0; int fi=-1; bool is_neg=false; while(true){ char g=getchar(); if(g=='-'){ assert(fi==-1); is_neg=true; continue; } if('0'<=g && g<='9'){ x*=10; x+=g-'0'; if(cnt==0){ fi=g-'0'; } cnt++; assert(fi!=0 || cnt==1); assert(fi!=0 || is_neg==false); assert(!(cnt>19 || ( cnt==19 && fi>1) )); } else if(g==endd){ assert(cnt>0); if(is_neg){ x= -x; } assert(l<=x && x<=r); return x; } else { assert(false); } } } string readString(int l,int r,char endd){ string ret=""; int cnt=0; while(true){ char g=getchar(); assert(g!=-1); if(g==endd){ break; } cnt++; ret+=g; } assert(l<=cnt && cnt<=r); return ret; } long long readIntSp(long long l,long long r){ return readInt(l,r,' '); } long long readIntLn(long long l,long long r){ return readInt(l,r,'\n'); } string readStringLn(int l,int r){ return readString(l,r,'\n'); } string readStringSp(int l,int r){ return readString(l,r,' '); } int sum = 0; int const MOD = (int)1e9 + 7; int a[100010], ways[100010]; void solve() { int n = readIntLn(2, 1e5); assert (n % 2 == 0); sum += n; assert (sum <= 1e6); map f; for (int i = 1; i <= n; ++i) { if (i < n) { a[i] = readIntSp(1, 1e6); } else { a[i] = readIntLn(1, 1e6); } f[a[i]] += 1; } int odd = 0; int ans = 1; for (auto &it : f) { if (odd) { ans = 1LL * ans * it.second % MOD; --it.second; } ans = 1LL * ans * ways[it.second / 2 * 2] % MOD; odd = 0; if (it.second % 2 == 1) { ans = 1LL * ans * it.second % MOD; odd = 1; } } cout << ans << "\n"; } /*int used[100010]; int result; void getAnswer(int n, int dep = 0, int cur = 1) { if (dep == n) { ++result; return; } while (used[cur] != 0) { ++cur; } for (int j = cur + 1; j <= 2 * n; ++j) { if (used[j] != 0) { continue; } used[cur] = dep + 1; used[j] = dep + 1; getAnswer(n, dep + 1, cur); used[cur] = 0; used[j] = 0; } }*/ int main(){ // freopen("input.txt", "r", stdin); ways[0] = 1; for (int i = 2; i < 100010; i += 2) { ways[i] = 1LL * ways[i - 2] * (i - 1) % MOD; } int t = readIntLn(1, 1000); while (t --> 0) { solve(); } assert(getchar()==-1); }