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

class BIT
  def initialize(n)
    @n = (0 .. 1.0/0).lazy.map{|i| 2**i}.find{|x| x >= n} + 1
    @a = Array.new(@n, 0)
  end

  def f(i)
    r = 0
    j = i
    while j > 0
      r += @a[j]
      j -= j & -j
    end
    j = i
    while j < @n
      @a[j] += 1
      j += j & -j
    end
    r
  end
end

e = Array.new(N + 1, 0)
N.times{|i| e[i + 1] = (e[i]*2 + 1) % M}
t = XYs.sort.map.with_index{|(x, y), i| [y, i + 1]}.sort
bt1, bt2 = BIT.new(N), BIT.new(N)
a = (0 ... N).map{|i| bt1.f(t[i].last)}
b = (N - 1).downto(0).each_with_object([]){|i, o| o[i] = bt2.f(t[i].last)}
ans = (0 ... N).inject(0){|r, i| (r + e[i - a[i]]*e[N - i - 1 - b[i]] + e[a[i]]*e[b[i]]) % M}
puts (e[N]*(N - 2) + 2*N + M - ans) % M