import sys

input = sys.stdin.readline

sys.setrecursionlimit(10 ** 7)



MOD = 998244353



N = int(eval(input()))

XY = [[int(x) for x in input().split()] for _ in range(N)]

XY.sort() # X ascending

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

Y_rank = {x:i for i,x in enumerate(sorted(Y),1)}



def BIT_update(tree,x):

    while x <= N:

        tree[x] += 1

        x += x & (-x)



def BIT_sum(tree,x):

    ret = 0

    while x:

        ret += tree[x]

        x -= x & (-x)

    return ret



pow2 = [1]

for _ in range(N):

    pow2.append(pow2[-1] * 2 % MOD)



answer = 0

tree = [0] * (N+1)

for L,(x,y) in enumerate(XY):

    y = Y_rank[y]

    R = N - 1 - L

    D = y - 1

    U = N - 1 - D

    LD = BIT_sum(tree,y)

    BIT_update(tree,y)

    LU = L - LD

    RD = D - LD

    RU = R - RD

    # bounding box が自分自身を含むような集合を数える

    # 全体から引く

    cnt = pow2[N]

    cnt -= pow2[L]

    cnt -= pow2[R]

    cnt -= pow2[D]

    cnt -= pow2[U]

    cnt += pow2[LD]

    cnt += pow2[LU]

    cnt += pow2[RD]

    cnt += pow2[RU]

    cnt -= 1

    answer += cnt



answer %= MOD



print(answer)

import sys

import numpy as np

import numba

from numba import njit

i8 = numba.int64



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



MOD = 998_244_353



@njit((i8[:], ), cache=True)

def build(raw_data):

    bit = raw_data.copy()

    for i in range(len(bit)):

        j = i + (i & (-i))

        if j < len(bit):

            bit[j] += bit[i]

    return bit





@njit((i8[:], i8), cache=True)

def get_sum(bit, i):

    s = 0

    while i:

        s += bit[i]

        i -= i & -i

    return s





@njit((i8[:], i8, i8), cache=True)

def add(bit, i, x):

    while i < len(bit):

        bit[i] += x

        i += i & -i





@njit((i8[:], i8), cache=True)

def find_kth_element(bit, k):

    N = len(bit)

    x, sx = 0, 0

    dx = 1

    while 2 * dx < N:

        dx *= 2

    while dx:

        y = x + dx

        if y < N:

            sy = sx + bit[y]

            if sy < k:

                x, sx = y, sy

        dx //= 2

    return x + 1



@njit((i8[:], ), cache=True)

def main(XY):

    X, Y = XY[::2], XY[1::2]

    N = len(Y)

    ind = X.argsort()

    X, Y = X[ind], Y[ind]

    # 座圧

    Y_sort = Y.copy()

    Y_sort.sort()

    Y = np.searchsorted(Y_sort, Y, 'right')

    bit = np.zeros(N + 10, np.int64)



    pow2 = np.ones(N + 10, np.int64)

    for n in range(1, N + 10):

        pow2[n] = 2 * pow2[n - 1] % MOD



    ret = 0

    for i in range(N):

        y = Y[i]

        L = i

        R = N - 1 - i

        LD = get_sum(bit, y)

        add(bit, y, 1)

        LU = L - LD

        D = y - 1

        U = N - 1 - D

        RD = D - LD

        RU = R - RD



        x = pow2[N] - 1

        x -= pow2[L] + pow2[R] + pow2[D] + pow2[U]

        x += pow2[LD] + pow2[LU] + pow2[RD] + pow2[RU]

        ret += x

    return ret % MOD



N = int(readline())

XY = np.array(read().split(), np.int64)



print((main(XY)))
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
MOD = 998244353
N = int(eval(input()))
XY = [[int(x) for x in input().split()] for _ in range(N)]
XY.sort()  # X ascending
X, Y = list(zip(*XY))
Y_rank = {x: i for i, x in enumerate(sorted(Y), 1)}


def BIT_update(tree, x):
    while x <= N:
        tree[x] += 1
        x += x & (-x)


def BIT_sum(tree, x):
    ret = 0
    while x:
        ret += tree[x]
        x -= x & (-x)
    return ret


pow2 = [1]
for _ in range(N):
    pow2.append(pow2[-1] * 2 % MOD)
answer = 0
tree = [0] * (N + 1)
for L, (x, y) in enumerate(XY):
    y = Y_rank[y]
    R = N - 1 - L
    D = y - 1
    U = N - 1 - D
    LD = BIT_sum(tree, y)
    BIT_update(tree, y)
    LU = L - LD
    RD = D - LD
    RU = R - RD
    # bounding box が自分自身を含むような集合を数える
    # 全体から引く
    cnt = pow2[N]
    cnt -= pow2[L]
    cnt -= pow2[R]
    cnt -= pow2[D]
    cnt -= pow2[U]
    cnt += pow2[LD]
    cnt += pow2[LU]
    cnt += pow2[RD]
    cnt += pow2[RU]
    cnt -= 1
    answer += cnt
answer %= MOD
print(answer)

import sys
import numpy as np
import numba
from numba import njit

i8 = numba.int64
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 998_244_353


@njit((i8[:],), cache=True)
def build(raw_data):
    bit = raw_data.copy()
    for i in range(len(bit)):
        j = i + (i & (-i))
        if j < len(bit):
            bit[j] += bit[i]
    return bit


@njit((i8[:], i8), cache=True)
def get_sum(bit, i):
    s = 0
    while i:
        s += bit[i]
        i -= i & -i
    return s


@njit((i8[:], i8, i8), cache=True)
def add(bit, i, x):
    while i < len(bit):
        bit[i] += x
        i += i & -i


@njit((i8[:], i8), cache=True)
def find_kth_element(bit, k):
    N = len(bit)
    x, sx = 0, 0
    dx = 1
    while 2 * dx < N:
        dx *= 2
    while dx:
        y = x + dx
        if y < N:
            sy = sx + bit[y]
            if sy < k:
                x, sx = y, sy
        dx //= 2
    return x + 1


@njit((i8[:],), cache=True)
def main(XY):
    X, Y = XY[::2], XY[1::2]
    N = len(Y)
    ind = X.argsort()
    X, Y = X[ind], Y[ind]
    # 座圧
    Y_sort = Y.copy()
    Y_sort.sort()
    Y = np.searchsorted(Y_sort, Y, "right")
    bit = np.zeros(N + 10, np.int64)
    pow2 = np.ones(N + 10, np.int64)
    for n in range(1, N + 10):
        pow2[n] = 2 * pow2[n - 1] % MOD
    ret = 0
    for i in range(N):
        y = Y[i]
        L = i
        R = N - 1 - i
        LD = get_sum(bit, y)
        add(bit, y, 1)
        LU = L - LD
        D = y - 1
        U = N - 1 - D
        RD = D - LD
        RU = R - RD
        x = pow2[N] - 1
        x -= pow2[L] + pow2[R] + pow2[D] + pow2[U]
        x += pow2[LD] + pow2[LU] + pow2[RD] + pow2[RU]
        ret += x
    return ret % MOD


N = int(readline())
XY = np.array(read().split(), np.int64)
print((main(XY)))

+import numpy as np +import numba +from numba import njit -input = sys.stdin.readline -sys.setrecursionlimit(10**7) -MOD = 998244353 -N = int(eval(input())) -XY = [[int(x) for x in input().split()] for _ in range(N)] -XY.sort()  # X ascending -X, Y = list(zip(*XY)) -Y_rank = {x: i for i, x in enumerate(sorted(Y), 1)} +i8 = numba.int64 +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +MOD = 998_244_353 -def BIT_update(tree, x): -    while x <= N: -        tree[x] += 1 -        x += x & (-x) +@njit((i8[:],), cache=True) +def build(raw_data): +    bit = raw_data.copy() +    for i in range(len(bit)): +        j = i + (i & (-i)) +        if j < len(bit): +            bit[j] += bit[i] +    return bit -def BIT_sum(tree, x): -    ret = 0 -    while x: -        ret += tree[x] -        x -= x & (-x) -    return ret +@njit((i8[:], i8), cache=True) +def get_sum(bit, i): +    s = 0 +    while i: +        s += bit[i] +        i -= i & -i +    return s -pow2 = [1] -for _ in range(N): -    pow2.append(pow2[-1] * 2 % MOD) -answer = 0 -tree = [0] * (N + 1) -for L, (x, y) in enumerate(XY): -    y = Y_rank[y] -    R = N - 1 - L -    D = y - 1 -    U = N - 1 - D -    LD = BIT_sum(tree, y) -    BIT_update(tree, y) -    LU = L - LD -    RD = D - LD -    RU = R - RD -    # bounding box が自分自身を含むような集合を数える -    # 全体から引く -    cnt = pow2[N] -    cnt -= pow2[L] -    cnt -= pow2[R] -    cnt -= pow2[D] -    cnt -= pow2[U] -    cnt += pow2[LD] -    cnt += pow2[LU] -    cnt += pow2[RD] -    cnt += pow2[RU] -    cnt -= 1 -    answer += cnt -answer %= MOD -print(answer) +@njit((i8[:], i8, i8), cache=True) +def add(bit, i, x): +    while i < len(bit): +        bit[i] += x +        i += i & -i + + +@njit((i8[:], i8), cache=True) +def find_kth_element(bit, k): +    N = len(bit) +    x, sx = 0, 0 +    dx = 1 +    while 2 * dx < N: +        dx *= 2 +    while dx: +        y = x + dx +        if y < N: +            sy = sx + bit[y] +            if sy < k: +                x, sx = y, sy +        dx //= 2 +    return x + 1 + + +@njit((i8[:],), cache=True) +def main(XY): +    X, Y = XY[::2], XY[1::2] +    N = len(Y) +    ind = X.argsort() +    X, Y = X[ind], Y[ind] +    # 座圧 +    Y_sort = Y.copy() +    Y_sort.sort() +    Y = np.searchsorted(Y_sort, Y, "right") +    bit = np.zeros(N + 10, np.int64) +    pow2 = np.ones(N + 10, np.int64) +    for n in range(1, N + 10): +        pow2[n] = 2 * pow2[n - 1] % MOD +    ret = 0 +    for i in range(N): +        y = Y[i] +        L = i +        R = N - 1 - i +        LD = get_sum(bit, y) +        add(bit, y, 1) +        LU = L - LD +        D = y - 1 +        U = N - 1 - D +        RD = D - LD +        RU = R - RD +        x = pow2[N] - 1 +        x -= pow2[L] + pow2[R] + pow2[D] + pow2[U] +        x += pow2[LD] + pow2[LU] + pow2[RD] + pow2[RU] +        ret += x +    return ret % MOD + + +N = int(readline()) +XY = np.array(read().split(), np.int64) +print((main(XY)))