package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func NextFloat() float64 {
  n, _ := strconv.ParseFloat(NextLine(), 64)
  return n
}
func NextFloatVec() []float64 {
  L := strings.Split(NextLine(), " ")
  N := make([]float64, len(L))
  for i := range N {
    N[i], _ = strconv.ParseFloat(L[i], 64)
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

type BinaryIndexedTree []int
func (BIT BinaryIndexedTree) Get(idx int) int {
  b := 0
  for i := idx; 0 < i; i -= i & (-i) {
    b += BIT[i]
  }
  return b
}
func (BIT *BinaryIndexedTree) Update(idx, v int) {
  N := len((*BIT))
  d := v - BIT.Get(idx) + BIT.Get(idx - 1)
  for i := idx; i < N; i += i & (-i) {
    (*BIT)[i] += d
  }
}
func (BIT BinaryIndexedTree) Query(s, t int) int {
  return BIT.Get(t) - BIT.Get(s)
}
func (BIT *BinaryIndexedTree) Increment(idx int) {
  N := len((*BIT))
  for i := idx; i < N; i += i & (-i) {
    (*BIT)[i]++
  }
}

func InitBIT(N int) BinaryIndexedTree {
  BIT := make([]int, N + 1)
  return BIT
}

type Axis [][]int
func (A Axis) Len() int { return len(A) }
func (A Axis) Less(i, j int) bool { return A[i][0] < A[j][0] }
func (A Axis) Swap(i, j int) { A[i], A[j] = A[j], A[i] }

const p = 998244353

func Solve() {
  N := NextInt()
  X := make([][]int, N)
  Y := make([][]int, N)
  for i := range X {
    XY := NextIntVec()
    X[i] = []int{XY[0], i + 1, 0}
    Y[i] = []int{XY[1], i}
  }
  sort.Sort(Axis(Y))
  for i, y := range Y {
    X[y[1]][2] = i + 1
  }
  sort.Sort(Axis(X))
  BITL := InitBIT(N)
  BITR := InitBIT(N)
  for i := 1; i <= N; i++ {
    BITR.Update(i, 1)
  }
  B := make([]int, N + 1)
  B[0] = 1
  for i := range B[1:] {
    B[i + 1] = 2 * B[i] % p
  }
  cnt := B[N - 1] * N % p
  for _, x := range X {
    BITR.Update(x[2], 0)
    LD, LU := BITL.Query(0, x[2]), BITL.Query(x[2], N)
    RD, RU := BITR.Query(0, x[2]), BITR.Query(x[2], N)
    cnt += ((B[LD] - 1) * (B[RU] - 1) % p) * B[N - 1 - LD - RU] % p
    cnt += ((B[LU] - 1) * (B[RD] - 1) % p) * B[N - 1 - LU - RD] % p
    cnt -= (((B[LD] - 1) * (B[RU] - 1) % p) * (B[LU] - 1) % p) * (B[RD] - 1) % p
    cnt %= p
    BITL.Update(x[2], 1)
  }
  Write(cnt)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 33920