#include <bits/stdc++.h>
using namespace std;

const int LOGN = 22;
const int N = (1 << LOGN);
const int mod = 998244353;
const int g = 3;
vector<int> w[LOGN];
vector<int> iw[LOGN];
vector<int> rv[LOGN];

inline int mul(int a, int b){
    return (a * 1ll * b) % mod;
}
inline int norm(int a){
    while(a >= mod)
        a -= mod;
    while(a < 0)
        a += mod;
    return a;
}
inline int binPow(int a, int k){
    int ans = 1;
    while(k > 0){
        if(k & 1)
            ans = mul(ans, a);
        a = mul(a, a);
        k >>= 1;
    }
    return ans;
}
inline int inv(int a){
    return binPow(a, mod - 2);
}

void precalc(){
    int wb = binPow(g, (mod - 1) / (1 << LOGN));

    for(int st = 0; st < LOGN - 1; st++){
        w[st].assign(1 << st, 1);

        int bw = binPow(wb, 1 << (LOGN - st - 1));
        int cw = 1;

        for(int k = 0; k < (1 << st); k++) {
            w[st][k] = cw;
            cw = mul(cw, bw);
        }
    }
    for(int st = 0; st < LOGN; st++){
        rv[st].assign(1 << st, 0);

        if(st == 0){
            rv[st][0] = 0;
            continue;
        }
        int h = (1 << (st - 1));
        for(int k = 0; k < (1 << st); k++)
            rv[st][k] = (rv[st - 1][k & (h - 1)] << 1) | (k >= h);
    }
}

inline void fft(int a[N], int n, bool inverse){
    int ln = 0;
    while((1 << ln) < n)
        ln++;

    assert((1 << ln) < N);
    n = (1 << ln);

    for(int i=0;i<n;i++){
        int ni = rv[ln][i];
        if(i < ni)
            swap(a[i], a[ni]);
    }

    for(int st = 0; (1 << st) < n; st++) {
        int len = (1 << st);
        for(int k = 0; k < n; k += (len << 1)) {
            for(int pos = k; pos < k + len; pos++) {
                int l = a[pos];
                int r = mul(a[pos + len], w[st][pos - k]);

                a[pos] = norm(l + r);
                a[pos + len] = norm(l - r);
            }
        }
    }

    if(inverse) {
        int in = inv(n);
        for(int i=0;i<n;i++)
            a[i] = mul(a[i], in);
        reverse(a + 1, a + n);
    }
}

int aa[N], bb[N], cc[N];
inline vector<int> multiply(const vector<int> a, const vector<int> b) {
    int n = 1;
    while(n < (a.size() + b.size()))
        n <<= 1;
        
    for(int i=0;i<n;i++)
        aa[i] = (i < a.size() ? a[i] : 0);
        
    for(int i=0;i<n;i++)
        bb[i] = (i < b.size() ? b[i] : 0);
        
    fft(aa, n, false);
    fft(bb, n, false);
    
    for(int i=0;i<n;i++)
        cc[i] = mul(aa[i], bb[i]);
        
    fft(cc, n, true);
    
    vector<int> c(n, 0);
    for(int i=0;i<c.size();i++)
        c[i] = cc[i];
    
    while(c.size() > 1 && c.back() == 0)
        c.pop_back();
    return c;
}

long long f1[100005], f2[100005];
long long pw(long long x, long long y){
    long long z=1;
    while(y){
        if(y&1) z=z*x%mod;
        x = x*x%mod;
        y>>=1;
    }
    return z;
}
long long func(int x, int y){
    if(y > x) return 0;
    return f1[x]*f2[y]%mod*f2[x-y]%mod;
}
int h[100005];
long long dp[100005];
int cnt[100005];
vector<int> val[1000005];
int main(){
    dp[0] = 1;
    dp[1] = 1;
    for(int i=2;i<=100000;i++){
        dp[i] = dp[i-1]*(i*2-1)%mod;
    }
    f1[0] = f2[0] = 1;
    for(int i=1;i<=100000;i++){
        f1[i] = f1[i-1]*i%mod;
        f2[i] = pw(f1[i], mod-2);
    }
    int n;
    scanf("%d", &n);
    for(int i=1;i<=2*n;i++) scanf("%d", &h[i]), cnt[h[i]]++;
    precalc();

    multiset<pair<int, int> > st; 
    for(int i=1;i<=100000;i++){
        if(cnt[i] >= 2){
            val[i].emplace_back(1);
            for(int j=1;j<=cnt[i]/2;j++) val[i].emplace_back(func(cnt[i], j*2)*dp[j]%mod);
            st.insert(make_pair(val[i].size(), i));
        }
    }
    while(st.size() > 1){
        int u = st.begin()->second;
        st.erase(st.begin());
        int v = st.begin()->second;
        st.erase(st.begin());
        val[u] = multiply(val[u], val[v]);
        st.insert(make_pair(val[u].size(), u));
    }

    long long ans = 0;
    if(st.empty()){
        ans = (ans + dp[n])%mod;
    }
    else{
        int u = st.begin()->second;
        for(int i=0;i<=n;i++){
            long long tmp = dp[n-i];
            if(val[u].size() > i) tmp = tmp*val[u][i]%mod;
            else tmp = 0;
            if(i%2 == 0) ans = (ans + tmp)%mod;
            else ans = (ans - tmp + mod)%mod;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 60552