import atexit
import os
import sys
import __pypy__

class NumberTheroemTransform:
  def __init__(self, mod, pr):
    self.mod = mod
    self.pr = pr
    self.M = 2
    self.w = [1]
    self.y = [1]

  def setwy(self, M):
    if M <= self.M:
      return
    self.w += [0] * ((M - self.M) // 2)
    self.y += [0] * ((M - self.M) // 2)
    self.M = M
    z = pow(self.pr, (self.mod - 1) // self.M, self.mod)
    x = pow(z, self.mod - 2, self.mod)
    j = M // 4
    while j:
      self.w[j] = z
      z = z * z % self.mod
      self.y[j] = x
      x = x * x % self.mod
      j //= 2
    self.y[0] = 1
    self.w[0] = 1
    j = self.M // 2
    js = 2
    while js < j:
      z = self.w[js]
      x = self.y[js]
      for k2 in range(js):
        self.w[k2 + js] = self.w[k2] * z % self.mod
        self.y[k2 + js] = self.y[k2] * x % self.mod
      js *= 2

  def fft(self, a):
    mod = self.mod
    self.setwy(len(a))
    u = 1
    v = len(a) >> 1
    while v:
      for j in range(v):
        a[j], a[j + v] = a[j] + a[j + v], a[j] - a[j + v]
        if a[j] >= mod:
          a[j] -= mod
        if a[j + v] < 0:
          a[j + v] += mod
      for jh in range(1, u):
        wj = self.w[jh]
        js = jh * v * 2
        je = js + v
        for j in range(js, je):
          ajv = wj * a[j + v] % mod
          a[j + v] = a[j] - ajv
          if a[j + v] < 0:
            a[j + v] += mod
          a[j] = a[j] + ajv
          if a[j] >= mod:
            a[j] -= mod
      u *= 2
      v >>= 1

  def ifft(self, a):
    mod = self.mod
    self.setwy(len(a))
    u = len(a) >> 1
    v = 1
    while u:
      for j in range(v):
        a[j], a[j + v] = a[j] + a[j + v], a[j] - a[j + v]
        if a[j] >= mod:
          a[j] -= mod
        if a[j + v] < 0:
          a[j + v] += mod
      for jh in range(1, u):
        wj = self.y[jh]
        js = jh * v * 2
        je = js + v
        for j in range(js, je):
          ajv = a[j] - a[j + v]
          if ajv < 0:
            ajv += mod
          a[j] = a[j] + a[j + v]
          if a[j] >= mod:
            a[j] -= mod
          a[j + v] = wj * ajv % mod
      u >>= 1
      v *= 2

  def multiply(self, s, t):
    sl, tl = len(s), len(t)
    L = sl + tl - 1
    M = 2 ** (L - 1).bit_length()
    s += [0] * (M - sl)
    t += [0] * (M - tl)
    self.fft(s)
    self.fft(t)
    for i in range(M):
      s[i] = s[i] * t[i] % self.mod
    self.ifft(s)
    invk = pow(M, self.mod - 2, self.mod)
    for i in range(L):
      s[i] = s[i] * invk % self.mod
    del s[L:]
    return s

ntt = NumberTheroemTransform(998244353, 3)

class Fastio:
  def __init__(self):
    self.ibuf = bytes()
    self.pil = 0
    self.pir = 0
    self.sb = __pypy__.builders.StringBuilder()

  def load(self):
    self.ibuf = self.ibuf[self.pil:]
    self.ibuf += os.read(0, 131072)
    self.pil = 0
    self.pir = len(self.ibuf)

  def flush(self):
    os.write(1, self.sb.build().encode())

  def fastin(self):
    if self.pir - self.pil < 32:
      self.load()
    minus = 0
    x = 0
    while self.ibuf[self.pil] < 45:
      self.pil += 1
    if self.ibuf[self.pil] == 45:
      minus = 1
      self.pil += 1
    while self.ibuf[self.pil] >= 48:
      x = x * 10 + (self.ibuf[self.pil] & 15)
      self.pil += 1
    if minus:
      x = -x
    return x

  def fastout(self, x):
    self.sb.append(str(x))

  def fastoutln(self, x):
    self.sb.append(str(x) + '\n')


fastio = Fastio()
rd = fastio.fastin
wt = fastio.fastout
wtn = fastio.fastoutln
atexit.register(fastio.flush)


MOD = 998244353
M = 100100
f = [0] * M
g = [0] * M
h = [0] * M
f[0] = g[0] = f[1] = g[1] = h[1] = 1
for i in range(2, M):
  f[i] = f[i - 1] * i % MOD
  h[i] = MOD - h[MOD % i] * (MOD // i) % MOD
  g[i] = g[i - 1] * h[i] % MOD

N = rd()
cnt = [0] * M
for i in range(N * 2):
  n = rd()
  cnt[n] += 1

class C:
  def __init__(sl, a):
    sl.a = a

  def __lt__(sl, ot):
    return len(sl.a) < len(ot.a)

lst = [C([1])]
for x in cnt:
  if x < 2:
    continue
  v = [0] * (x // 2 + 1)
  c = 1
  n = x
  m = 0
  for i in range(x // 2 + 1):
    if i != 0:
      c = c * n % MOD * (n - 1) % MOD
      if c & 1:
        c = (c + MOD) // 2
      else:
        c //= 2
      n -= 2
      m += 1
    v[i] = c * g[m] % MOD
  lst.append(C(v))



import heapq

heapq.heapify(lst)
while len(lst) > 1:
  a = heapq.heappop(lst)
  b = heapq.heappop(lst)
  c = ntt.multiply(a.a, b.a)
  heapq.heappush(lst, C(c))
f = lst[0].a

pre = [0] * (N + 1)
n = 2 * N
m = 0
c = 1
for i in range(N + 1):
  if i != 0:
    c = c * (i * 2) % MOD * (i * 2 - 1) % MOD
    c = (c + MOD) >> 1 if c & 1 else c >> 1
    m += 1
  pre[i] = c * g[m] % MOD
ans = 0
for i in range(len(f)):
  c = f[i] * pre[N - i]
  ans += -c if i & 1 else c
print(ans % MOD)

Measured memory_bytes: 103020