#include using namespace std; const int maxn = 2e5, mod = 1e9 + 7; int t, n, a[maxn + 10], b[maxn + 10], m; int f[maxn + 10][3]; int fac[maxn + 10], inv[maxn + 10], ifac[maxn + 10]; inline void addto(int &x, int y) { x += y; if (x >= mod) x -= mod; } inline int dec(int x, int y) { x -= y; return x < 0 ? x + mod : x; } inline int mul(int x, int y) { return 1ll * x * y % mod; } void pre() { fac[0] = ifac[0] = 1; for (int i = 1; i <= maxn; ++i) { fac[i] = mul(fac[i - 1], i); inv[i] = i == 1 ? 1 : dec(0, mul(mod / i, inv[mod % i])); ifac[i] = mul(ifac[i - 1], inv[i]); } } int comb(int x, int y) { return mul(fac[x], mul(ifac[y], ifac[x - y])); } int main() { pre(); scanf("%d", &t); while (t--) { scanf("%d", &n); for (int i = 1; i <= n * 2; ++i) scanf("%d", &a[i]); sort(a + 1, a + n * 2 + 1); m = 0; for (int i = 1, lst; i <= n * 2; i = lst) { for (lst = i; lst <= n * 2 && a[lst] == a[i]; ++lst); ++m; b[m] = lst - i; } for (int i = 0; i <= m + 1; ++i) f[i][0] = f[i][1] = f[i][2] = 0; f[1][0] = 1; for (int i = 1; i <= m; ++i) for (int j = 0; j < 3; ++j) { int w = b[i] - !!j; if (w & 1) { addto(f[i + 1][1], mul(f[i][j], comb(b[i], w / 2 + (j == 1)))); addto(f[i + 1][2], mul(f[i][j], comb(b[i], w / 2 + 1 + (j == 1)))); } else { addto(f[i + 1][0], mul(f[i][j], comb(b[i], w / 2 + (j == 1)))); } } printf("%d\n", f[m + 1][0]); } }