#include <cstring>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
using namespace std;

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

const int M = 998244353;

int main() {
    int n; cin >> n;
    pair<int, int> p[n]; for (int i = 0; i < n; i++) cin >> p[i].first >> p[i].second;
    sort(p, p+n, [](pair<int, int> &x, pair<int, int> &y) {
            return x.second < y.second;
        });
    for (int i = 0; i < n; i++) p[i].second = i+1;
    sort(p, p+n);
    int L[n+2], R[n+2];
    memset(L, 0, sizeof(L));
    memset(R, 0, sizeof(R));
    for (int i = 0; i < n; i++)
        for (int j = p[i].second; j <= n; j += j&-j) R[j]++;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int a, b = 0, c, d = 0, y = p[i].second;
        for (int j = y; j > 0; j -= j&-j) b += L[j], d += R[j];
        d--;
        a = i - b; c = n-i-1-d;
        ans += modexp(2, n, M) - (modexp(2, a, M) + modexp(2, d, M) - 1) * (modexp(2, b, M) + modexp(2, c, M) - 1) % M;
        ans %= M;
        for (int j = y; j <= n; j += j&-j) L[j]++, R[j]--;
    }
    cout << (ans % M + M) % M << endl;
}
