#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define mp make_pair

#define ll long long
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())

using namespace std;

const int MAXN = (int) 3e5 + 10;
const int mod = (int)998244353;

int n;
pii a[MAXN];
int p[MAXN];

int sum(int x, int y) {
    x += y;
    if ( x < 0) x += mod;
    if (x >= mod) x -= mod;
    return x;
}
void add(int &x, int y) {
    x =sum(x,y);
}

int t[MAXN];

int get(int i) {
    i=a[i].s;
    int cnt=0;
    while(i>=0){
        cnt+=t[i];
        i=(i&(i+1))-1;
    }
    return cnt;
}

void upd(int i){
    i=a[i].s;
    while(i<n){
        t[i]++;
        i|=i+1;
    }
}

int main() {
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++) {
        cin >> a[i].f >> a[i].s;
        v.pb(a[i].s);
    }
    sort(all(v));
    for (int i = 0; i < n; i++) {
        a[i].s=lower_bound(all(v), a[i].s)-v.begin();
    }
    p[0]=1;
    for (int i = 1; i <= n; i++) p[i]=sum(p[i-1],p[i-1]);
    sort(a, a + n);
    int ans = 0;
    for (int i = 0; i < n; i++){
        add(ans, sum(p[n],-1));
    }
    for (int i = 0; i < n; i++){
        add(ans, -sum(p[i],-1));
        add(ans, -sum(p[n-i-1],-1));
    }
    for (int i = 0; i < n; i++){
        add(ans, -sum(p[i],-1));
        add(ans, -sum(p[n-i-1],-1));
    }
    for (int i = 0; i < n; i++){
        add(ans, sum(p[get(i)],-1));
        add(ans, sum(p[i-get(i)],-1));
        upd(i);
    }
    memset(t,0,sizeof(t));
    reverse(a,a+n);
    for (int i = 0; i < n; i++){
        add(ans, sum(p[get(i)],-1));
        add(ans, sum(p[i-get(i)],-1));
        upd(i);
    }
    cout << ans;
    return 0;
}
