N = gets.to_i
XYs = readlines.map{|l| l.split.map(&:to_i)}
M = 998244353

sub = ->(a, b){(a - b) % M}
t = 1
dd = [t]
N.times do
  t = 2*t % M
  dd << t
end
xs, ys = XYs.transpos
ini = N.times.sort_by{|n| xs[n]}
N.times.sort_by{|n| ys[n]}.each_with_index{|yi, i| ys[yi] = i}
nys = ini.map{|i| ys[i]}
tree = [0]*(N + 1)
r = 0
nys.each_with_index do |y, i|
  j = y + 1
  while j <= N
    tree[j] += 1
    j += j & -j
  end
  d = 0
  j = y
  while j > 0
    d += tree[j]
    j -= j & -j
  end
  c = i - d
  b = (N - 1) - y - c
  a = (N - 1) - b - c - d
  r = (r + sub[dd[b + c] + dd[c + d] + dd[d + a] + dd[a + b], dd[a] + dd[b] + dd[c] + dd[d]]) % M
end
puts sub[dd[N]*N % M, (r + N) % M]