import sys

input = sys.stdin.readline

mod = 998244353

n = int(eval(input()))

XY = sorted(tuple(map(int, input().split())) for _ in range(n))

X, Y = list(zip(*XY))

L = {y:i+1 for i, y in enumerate(sorted(Y))}

Y = tuple(L[y] for y in Y)

BIT = [0]*(n+1)

def add(i):

  while i<=n:

    BIT[i] += 1

    i += i&-i

def acc(i):

  res = 0

  while i:

    res += BIT[i]

    i -= i&-i

  return res

A = [0]*n

B = [0]*n

C = [0]*n

D = [0]*n

for i, y in enumerate(Y):

  A[i] = acc(y)

  B[i] = i - A[i]

  add(y)

BIT = [0]*(n+1)

for i in range(n-1, -1, -1):

  y = Y[i]

  C[i] = acc(y)

  D[i] = n-1-i - C[i]

  add(y)

ans = pow(2, n-1, mod) * n % mod

for a, b, c, d in zip(A, B, C, D):

  a = pow(2, a, mod)

  b = pow(2, b, mod)

  c = pow(2, c, mod)

  d = pow(2, d, mod)

  temp = (a-1)*b*c*(d-1) + a*(b-1)*(c-1)*d - (a-1)*(b-1)*(c-1)*(d-1)

  ans += temp

  ans %= mod

print(ans)
import sys

input = sys.stdin.readline

mod = 998244353

n = int(eval(input()))

XY = sorted(tuple(map(int, input().split())) for _ in range(n))

X, Y = list(zip(*XY))

L = {y:i+1 for i, y in enumerate(sorted(Y))}

Y = tuple(L[y] for y in Y)

BIT = [0]*(n+1)

def add(i):

  while i<=n:

    BIT[i] += 1

    i += i&-i

def acc(i):

  res = 0

  while i:

    res += BIT[i]

    i -= i&-i

  return res

A = [0]*n

B = [0]*n

C = [0]*n

D = [0]*n

for i, y in enumerate(Y):

  A[i] = acc(y)

  B[i] = i - A[i]

  add(y)

BIT = [0]*(n+1)

for i in range(n-1, -1, -1):

  y = Y[i]

  C[i] = acc(y)

  D[i] = n-1-i - C[i]

  add(y)

T = [1]*n

for i in range(n-1):

  T[i+1] = T[i]*2%mod

ans = T[n-1] * n % mod

for a, b, c, d in zip(A, B, C, D):

  a = T[a]

  b = T[b]

  c = T[c]

  d = T[d]

  temp = (a-1)*b*c*(d-1) + a*(b-1)*(c-1)*d - (a-1)*(b-1)*(c-1)*(d-1)

  ans += temp

  ans %= mod

print(ans)
import sys

input = sys.stdin.readline
mod = 998244353
n = int(eval(input()))
XY = sorted(tuple(map(int, input().split())) for _ in range(n))
X, Y = list(zip(*XY))
L = {y: i + 1 for i, y in enumerate(sorted(Y))}
Y = tuple(L[y] for y in Y)
BIT = [0] * (n + 1)


def add(i):
    while i <= n:
        BIT[i] += 1
        i += i & -i


def acc(i):
    res = 0
    while i:
        res += BIT[i]
        i -= i & -i
    return res


A = [0] * n
B = [0] * n
C = [0] * n
D = [0] * n
for i, y in enumerate(Y):
    A[i] = acc(y)
    B[i] = i - A[i]
    add(y)
BIT = [0] * (n + 1)
for i in range(n - 1, -1, -1):
    y = Y[i]
    C[i] = acc(y)
    D[i] = n - 1 - i - C[i]
    add(y)
ans = pow(2, n - 1, mod) * n % mod
for a, b, c, d in zip(A, B, C, D):
    a = pow(2, a, mod)
    b = pow(2, b, mod)
    c = pow(2, c, mod)
    d = pow(2, d, mod)
    temp = (
        (a - 1) * b * c * (d - 1)
        + a * (b - 1) * (c - 1) * d
        - (a - 1) * (b - 1) * (c - 1) * (d - 1)
    )
    ans += temp
    ans %= mod
print(ans)

import sys

input = sys.stdin.readline
mod = 998244353
n = int(eval(input()))
XY = sorted(tuple(map(int, input().split())) for _ in range(n))
X, Y = list(zip(*XY))
L = {y: i + 1 for i, y in enumerate(sorted(Y))}
Y = tuple(L[y] for y in Y)
BIT = [0] * (n + 1)


def add(i):
    while i <= n:
        BIT[i] += 1
        i += i & -i


def acc(i):
    res = 0
    while i:
        res += BIT[i]
        i -= i & -i
    return res


A = [0] * n
B = [0] * n
C = [0] * n
D = [0] * n
for i, y in enumerate(Y):
    A[i] = acc(y)
    B[i] = i - A[i]
    add(y)
BIT = [0] * (n + 1)
for i in range(n - 1, -1, -1):
    y = Y[i]
    C[i] = acc(y)
    D[i] = n - 1 - i - C[i]
    add(y)
T = [1] * n
for i in range(n - 1):
    T[i + 1] = T[i] * 2 % mod
ans = T[n - 1] * n % mod
for a, b, c, d in zip(A, B, C, D):
    a = T[a]
    b = T[b]
    c = T[c]
    d = T[d]
    temp = (
        (a - 1) * b * c * (d - 1)
        + a * (b - 1) * (c - 1) * d
        - (a - 1) * (b - 1) * (c - 1) * (d - 1)
    )
    ans += temp
    ans %= mod
print(ans)

-ans = pow(2, n - 1, mod) * n % mod +T = [1] * n +for i in range(n - 1): +    T[i + 1] = T[i] * 2 % mod +ans = T[n - 1] * n % mod -    a = pow(2, a, mod) -    b = pow(2, b, mod) -    c = pow(2, c, mod) -    d = pow(2, d, mod) +    a = T[a] +    b = T[b] +    c = T[c] +    d = T[d]