module mod_fenwick_tree
  implicit none
  type fenwick_tree
    integer :: n
    integer, pointer :: arr(:) => null()
  end type fenwick_tree
  private
  public :: fenwick_tree, init_bit, release_bit
  public :: add, summate, update, maximum
contains
  subroutine init_bit(bit,n)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: n
    bit%n = n
    allocate(bit%arr(n))
    bit%arr = 0
    return
  end subroutine init_bit
  subroutine release_bit(bit)
    implicit none
    type(fenwick_tree) :: bit
    if (associated(bit%arr)) deallocate(bit%arr)
    return
  end subroutine release_bit
  subroutine add(bit,i,v)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i
    integer, intent(in) :: v
    integer :: x
    x = i
    do while (x <= bit%n)
      bit%arr(x) = bit%arr(x)+v
      x = x+and(x,-x)
    end do
    return
  end subroutine add
  function summate(bit,i) result(s)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i
    integer :: x
    integer :: s
    x = i
    s = 0
    do while (x > 0)
      s = s+bit%arr(x)
      x = x-and(x,-x)
    end do
    return
  end function summate
  subroutine update(bit,i,v)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i
    integer, intent(in) :: v
    integer :: x
    x = i
    do while (x <= bit%n)
      if (bit%arr(x) < v) bit%arr(x) = v
      x = x+and(x,-x)
    end do
    return
  end subroutine update
  function maximum(bit,i) result(m)
    implicit none
    type(fenwick_tree) :: bit
    integer, intent(in) :: i
    integer :: x
    integer :: m
    x = i
    m = 0
    do while (x > 0)
      m = max(m,bit%arr(x))
      x = x-and(x,-x)
    end do
    return
  end function maximum
end module mod_fenwick_tree
program enclosed_points
  use mod_fenwick_tree
  implicit none
  type(fenwick_tree) :: bit
  integer(8), parameter :: md = 998244353_8
  integer :: n, x(200000) = 0, y(200000) = 0, p(200000) = 0, i, j
  integer :: a(200000,4) = 0
  integer(8) :: ans = 0_8, ok(4), ng(4)
  read(*,*) n
  do i = 1, n
    read(*,*) x(i), y(i)
  end do
  call compress(x(1:n))
  call compress(y(1:n))
  do i = 1, n
    p(x(i)) = y(i)
  end do
  call init_bit(bit,n)
  do i = 1, n
    a(i,1) = summate(bit,p(i))
    a(i,2) = i-a(i,1)-1
    call add(bit,p(i),1)
  end do
  call release_bit(bit)
  call init_bit(bit,n)
  do i = n, 1, -1
    a(i,3) = summate(bit,p(i))
    a(i,4) = n-i-a(i,3)
    call add(bit,p(i),1)
  end do
  call release_bit(bit)
  do i = 1, n
    do j = 1, 4
      ng(j) = pow(2_8,a(i,j))
      ok(j) = mod(md+ng(j)-1_8,md)
    end do
    ans = ans+mod(mod(ng(1)*ok(2),md)*mod(ok(3)*ng(4),md),md)
    ans = ans+mod(mod(ok(1)*ng(2),md)*mod(ng(3)*ok(4),md),md)
    ans = ans-mod(mod(ok(1)*ok(2),md)*mod(ok(3)*ok(4),md),md)
    ans = ans+mod(mod(ng(1)*ng(2),md)*mod(ng(3)*ng(4),md),md)
    ans = mod(ans+md,md)
  end do
  write(*,'(i0)') ans
  stop
contains
  recursive function pow(a,b) result(r)
    implicit none
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer(8) :: r
    r = 1_8
    if (b == 0) return
    if (mod(b,2) == 0) then
      r = pow(a,b/2)
      r = mod(r*r,md)
      return
    end if
    r = mod(a*pow(a,b-1),md)
    return
  end function pow
  subroutine compress(x)
    implicit none
    integer, intent(inout) :: x(:)
    integer :: y(size(x),2), i, n, k
    n = size(x)
    y(:,1) = x
    do i = 1, n
      y(i,2) = i
    end do
    call quick_sort(y,1)
    k = 0
    x(y(1,2)) = 1
    do i = 2, n
      if (y(i,1) == y(i-1,1)) k = k+1
      x(y(i,2)) = i-k
    end do
    return
  end subroutine compress
  recursive subroutine quick_sort(a,i)
    implicit none
    integer, intent(inout) :: a(:,:)
    integer, intent(in) :: i
    integer :: p, c(size(a(1,:)))
    integer :: n, l, r, m
    n = size(a(:,1))
    l = 1
    r = n
    m = (l+r)/2
    p = a(l,i)+a(m,i)+a(r,i)-max(a(l,i),a(m,i),a(r,i))-min(a(l,i),a(m,i),a(r,i))
    do
      do while (a(l,i) < p)
        l = l+1
      end do
      do while (a(r,i) > p)
        r = r-1
      end do
      if (l >= r) exit
      c = a(l,:)
      a(l,:) = a(r,:)
      a(r,:) = c
      l = l+1
      r = r-1
    end do
    if (l > 2) call quick_sort(a(1:l-1,:),i)
    if (n > r+1) call quick_sort(a(r+1:n,:),i)
    return
  end subroutine quick_sort
end program enclosed_points