#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) {
            os << ',';
        }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 998244353;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

#include <atcoder/all>
using namespace atcoder;

//-------------------------------------

using mint = modint998244353;

struct Combination {
    int MAX;
    vector<mint> fac, finv;
    Combination(int _MAX) : fac(_MAX), finv(_MAX), MAX(_MAX) {
        fac[0] = fac[1] = 1;
        for(int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i;
        }
        finv[MAX - 1] = fac[MAX - 1].inv();
        for(int i = MAX - 1; i >= 1; i--) {
            finv[i - 1] = finv[i] * i;
        }
    }
    mint COM(int n, int k) {
        if(n < k || n < 0 || k < 0) {
            return 0;
        }
        return fac[n] * finv[k] * finv[n - k];
    }
};

int main() {
    int N;
    cin >> N;
    vector<int> cnt(100100, 0);
    for(int i = 0; i < N + N; i++) {
        int h;
        cin >> h;
        cnt[h]++;
    }

    deque<vector<mint>> que;
    static Combination comb(300000);
    vector<mint> dubfac(100100, 1);

    for(int i = 1; i < 100100; i++) {
        dubfac[i] = dubfac[i - 1] * (2 * i - 1);
    }

    for(int h = 0; h < 100100; h++) {
        if(cnt[h] == 0) {
            continue;
        }
        int lim = cnt[h] / 2;
        vector<mint> c(lim + 1);
        for(int i = 0; i <= lim; i++) {
            c[i] = mint(i % 2 ? -1 : 1) * comb.COM(cnt[h], 2 * i) * dubfac[i];
        }
        que.push_back(c);
    }

    while((int)que.size() != 1) {
        auto v = convolution(que[0], que[1]);
        que.pop_front();
        que.pop_front();
        que.push_back(v);
    }

    mint ans = 0;
    auto c = que[0];
    int sz = (int)c.size();
    for(int i = 0; i < sz; i++) {
        ans += c[i] * dubfac[N - i];
    }
    cout << ans.val() << "\n";
}

Measured memory_bytes: 11876