object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt
  val XY = Array.fill(N)(sc.nextInt, sc.nextInt)
  val M = 998244353

  class BIT(x: Int){
    val n = Stream.from(0).map(Math.pow(2, _).toInt).find(_ >= x).get + 1
    val as = Array.fill(n)(0)

    def f(i: Int): Int = {
      var r = 0
      var j = i
      while (j > 0) {
        r += as(j)
        j -= j & -j
      }
      j = i
      while (j < n) {
        as(j) += 1
        j += j & -j
      }
      r
    }
  }

  val e = Array.fill(N + 1)(0)
  (0 until N).foreach{i => e(i + 1) = (e(i)*2 + 1) % M}
  val t = XY.sorted.zipWithIndex.map{case((x, y), i) => (y, i + 1)}.sorted
  val bt1 = new BIT(N)
  val bt2 = new BIT(N)
  val a = (0 until N).map{i => bt1.f(t(i)._2)}
  val b = (N - 1 to 0 by -1).map{i => bt2.f(t(i)._2)}.reverse
  val ans = (0 until N).foldLeft(0){(r, i) => (r + e(i - a(i))*e(N - i - 1 - b(i)) + e(a(i))*e(b(i))) % M}
  println((e(N)*(N - 2) + 2*N + M - ans) % M)
}