### BUGGY CODE ###

#!/usr/bin/env python3
import sys
import bisect

MOD = 998244353  # type: int

class BitIndexedTree(object):
    def __init__(self, N):
        self.V = [0] * N
        self.N = N
    
    def __getitem__(self, key):
        return self.sum(key, key+1)
    
    def __setitem__(self, key, value):
        diff = value - self[key]
        self.add(diff, key)

    def add(self, w, a):
        if w == 0:
            return
        x = a
        while x <= self.N:
            self.V[x-1] += w
            x += x & -x
    
    def sum(self, start=0, end=0):
        if end <= start:
            return 0
        if start > 0:
            return self.sum(0, end) - self.sum(0, start)
        x = end
        ret = 0
        while x > 0:
            ret += self.V[x-1]
            x -= x & -x
        return ret


def solve(N: int, P: "List[tuple]"):
    res = 0
    
    P.sort(key=lambda x: x[1])
    for i, p in enumerate(P):
        p[1] = i
    
    P.sort()
    for i, p in enumerate(P):
        p[0] = i
    left = BitIndexedTree(N)
    right = BitIndexedTree(N)

    ll = [0] * N
    lg = [0] * N
    gl = [0] * N
    gg = [0] * N

    for i, p in enumerate(P):
        ll[i] = left.sum(0, p[1])
        lg[i] = i-ll[i]
        left.add(1, p[1]+1)

    for i, p in list(enumerate(P))[::-1]:
        gl[i] = right.sum(0, p[1])
        gg[i] = N-i-1-gl[i]
        right.add(1, p[1]+1)

    for a1, a2, a3, a4 in zip(gg, lg, ll, gl):
        res += ((1 << a3) - 1) * ((1 << a1) - 1) * (1 << (a2+a4))
        res += ((1 << a2) - 1) * ((1 << a4) - 1) * (1 << (a3+a1))

        res -= ((1 << a2) - 1) * ((1 << a4) - 1) * ((1 << a1) - 1) * ((1 << a3) - 1)

        res += (1 << N-1)

        res %= MOD
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [()] * (N)  # type: "List[tuple]" 
    for i in range(N):
        x = int(next(tokens))
        y = int(next(tokens))
        P[i] = [x, y]
    solve(N, P)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import bisect

MOD = 998244353  # type: int

class BitIndexedTree(object):
    def __init__(self, N):
        self.V = [0] * N
        self.N = N
    
    def __getitem__(self, key):
        return self.sum(key, key+1)
    
    def __setitem__(self, key, value):
        diff = value - self[key]
        self.add(diff, key)

    def add(self, w, a):
        if w == 0:
            return
        x = a
        while x <= self.N:
            self.V[x-1] += w
            x += x & -x
    
    def sum(self, start=0, end=0):
        if end <= start:
            return 0
        if start > 0:
            return self.sum(0, end) - self.sum(0, start)
        x = end
        ret = 0
        while x > 0:
            ret += self.V[x-1]
            x -= x & -x
        return ret


def solve(N: int, P: "List[tuple]"):
    res = 0
    power = [1] * N
    for i in range(1, N):
        power[i] = power[i-1] * 2 % MOD

    P.sort(key=lambda x: x[1])
    for i, p in enumerate(P):
        p[1] = i
    
    P.sort()
    for i, p in enumerate(P):
        p[0] = i
    left = BitIndexedTree(N)
    right = BitIndexedTree(N)

    ll = [0] * N
    lg = [0] * N
    gl = [0] * N
    gg = [0] * N

    for i, p in enumerate(P):
        ll[i] = left.sum(0, p[1])
        lg[i] = i-ll[i]
        left.add(1, p[1]+1)

    for i, p in enumerate(P[::-1]):
        gl[-1-i] = right.sum(0, p[1])
        gg[-1-i] = i-gl[-1-i]
        right.add(1, p[1]+1)

    for a1, a2, a3, a4 in zip(gg, lg, ll, gl):
        b1 = power[a1]
        b2 = power[a2]
        b3 = power[a3]
        b4 = power[a4]

        res += (b1 - 1) * (b3 - 1) * b2 * b4
        res += (b2 - 1) * (b4 - 1) * b1 * b3

        res -= (b1 - 1) * (b2 - 1) * (b3 - 1) * (b4 - 1)

        res += b1 * b2 * b3 * b4

        res %= MOD
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [()] * (N)  # type: "List[tuple]" 
    for i in range(N):
        x = int(next(tokens))
        y = int(next(tokens))
        P[i] = [x, y]
    solve(N, P)

if __name__ == '__main__':
    main()