//@formatter:off
#include<bits/stdc++.h>
#include <atcoder/convolution>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

//constexpr int mod = 1000000007;
constexpr int mod = 998244353;

struct mint {
    ll x;
    
    constexpr mint(ll x = 0) : x((x % mod + mod) % mod) {}
    
    constexpr mint operator-() const { return mint(-x); }
    
    constexpr mint &operator+=(const mint &a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    constexpr mint &operator++() { return *this += mint(1); }
    
    constexpr mint &operator-=(const mint &a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    
    constexpr mint &operator--() { return *this -= mint(1); }
    
    constexpr mint &operator*=(const mint &a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    constexpr mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    
    constexpr mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    
    constexpr mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    
    constexpr mint pow(ll t) const {
        mint res = mint(1), a(*this);
        while (t > 0) {
            if (t & 1) res *= a;
            t >>= 1;
            a *= a;
        }
        return res;
    }
    
    // for prime mod
    constexpr mint inv() const { return pow(mod - 2); }
    
    constexpr mint &operator/=(const mint &a) { return *this *= a.inv(); }
    
    constexpr mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

class combination {
    vector<mint> fact, ifact;
public:
    
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(100010);

// Number Theoretic Transform
namespace NTT {
    void trans(vector<mint> &v, bool inverse = false) {
        int sz = v.size();
        if (sz == 1) return;
        vector<mint> a, b;
        rep(i, sz / 2) {
            a.pb(v[2 * i]);
            b.pb(v[2 * i + 1]);
        }
        trans(a, inverse);
        trans(b, inverse);
        mint m = mint(3).pow((mod - 1) / sz);
        if (inverse) m = m.inv();
        mint now = 1;
        rep(i, sz) {
            v[i] = a[i % (sz / 2)] + now * b[i % (sz / 2)];
            now *= m;
        }
    }
    
    vector<mint> multiply(const vector<mint> &f, const vector<mint> &g) {
        assert(mod == 998244353);
        vector<mint> nf, ng;
        int sz = 1;
        while (sz < f.size() + g.size() - 1) sz *= 2;
        nf.resize(sz);
        ng.resize(sz);
        rep(i, f.size()) nf[i] = f[i];
        rep(i, g.size()) ng[i] = g[i];
        trans(nf);
        trans(ng);
        rep(i, sz) nf[i] *= ng[i];
        trans(nf, true);
        rep(i, sz) nf[i] /= mint(sz);
        return nf;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    const int c = 100000;
    vi cnt(c);
    rep(i, n * 2) {
        int h;
        cin >> h;
        h--;
        cnt[h]++;
    }
    using vm = vector<mint>;
    auto cmp = [](const vm &a, const vm &b) { return a.size() > b.size(); };
    priority_queue<vm, vector<vm>, decltype(cmp)> pq{cmp};
    pq.push(vm(1, 1));
    rep(i, c) {
        if (cnt[i] <= 1) continue;
        vm temp(cnt[i] / 2 + 1);
        temp[0] = 1;
        mint now = 1;
        rep2(j, 1, cnt[i] / 2 + 1) {
            now *= comb(cnt[i] - 2 * (j - 1), 2);
            now /= j;
            temp[j] = now;
        }
        pq.push(temp);
    }
    while (pq.size() >= 2) {
        vm a = pq.top();
        pq.pop();
        vm b = pq.top();
        pq.pop();
        pq.push(NTT::multiply(a, b));
    }
    vm v = pq.top();
    mint ans = 0;
    mint m = 1;
    rep2(i, 1, n - v.size() + 1) {
        m *= 2 * i - 1;
    }
    rrep(i, v.size()) {
        if (i < n) m *= 2 * (n - i) - 1;
        
        mint now = m * v[i];
        if (i & 1) ans -= now;
        else ans += now;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11280