////////////////////////////////////////////    _LeMur_
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 998244353;

int n;
int x[N] , u[N];

map <int,int> mpx , mpu;
map <int,int>::iterator it;

int pw[N] , q[N];

vector <int> xx;
vector <int> uu;

pair <int,int> p[N];

int t[N];

void update(int pos){
    for(; pos <= 200000; pos += pos & -pos){
        t[pos]++;
    }
}

int get(int pos){
    int answ = 0;
    for(; pos > 0; pos -= pos & -pos){
        answ += t[pos];
    }
    return answ;
}

int get(int l,int r){
    return get(r) - get(l - 1);
}

int main(){
	mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n;
    for(int i=1;i<=n;i++){
        scanf("%d%d",&x[i],&u[i]);
        mpx[ x[i] ] = 1;
        mpu[ u[i] ] = 1;
    }
    int timer = 0;
    for(it = mpx.begin(); it != mpx.end(); ++it){
        mpx[ (*it).first ] = ++timer;
    }
    timer = 0;
    for(it = mpu.begin(); it != mpu.end(); ++it){
        mpu[ (*it).first ] = ++timer;
    }
    for(int i=1;i<=n;i++){
        x[i] = mpx[ x[i] ];
        u[i] = mpu[ u[i] ];
        xx.push_back(x[i]);
        uu.push_back(u[i]);
    }
    sort(xx.begin() , xx.end());
    sort(uu.begin() , uu.end());
    pw[0] = 1;
    q[0] = 0;
    for(int i=1;i<=n;i++){
        pw[i] = pw[i - 1] * 2 % mod;
        q[i] = (pw[i] - 1 + mod) % mod;
    }
    int answ = 0;
    for(int i=1;i<=n;i++){
        int id = upper_bound(xx.begin() , xx.end() , x[i]) - xx.begin();
        answ += q[ (int)xx.size() - id ];
        answ %= mod;
        id = upper_bound(uu.begin() , uu.end() , u[i]) - uu.begin();
        answ += q[ (int)uu.size() - id ];
        answ %= mod;
        id = lower_bound(xx.begin() , xx.end() , x[i]) - xx.begin() - 1;
        answ += q[id + 1];
        answ %= mod;
        id = lower_bound(uu.begin() , uu.end() , u[i]) - uu.begin() - 1;
        answ += q[id + 1];
        answ %= mod;
    }
    for(int i=1;i<=n;i++){
        p[i] = make_pair(x[i] , u[i]);
    }
    sort(p + 1 , p + n + 1);
    for(int i=1;i<=n;i++){
        int xx = p[i].first;
        int st = i;
        while(i <= n && p[i].first == xx){
            ++i;
        }
        --i;
        for(int j=st;j<=i;j++){
            answ -= q[ get(1 , p[j].second - 1) ];
            answ = (answ + mod) % mod;
            answ -= q[ get(p[j].second + 1 , 200000) ];
            answ = (answ + mod) % mod;
        }
        for(int j=st;j<=i;j++){
            update(p[j].second);
        }
    }
    reverse(p + 1 , p + n + 1);
    for(int i=1;i<=200000;i++){
        t[i] = 0;
    }
    for(int i=1;i<=n;i++){
        int xx = p[i].first;
        int st = i;
        while(i <= n && p[i].first == xx){
            ++i;
        }
        --i;
        for(int j=st;j<=i;j++){
            answ -= q[ get(1 , p[j].second - 1) ];
            answ = (answ + mod) % mod;
            answ -= q[ get(p[j].second + 1 , 200000) ];
            answ = (answ + mod) % mod;
        }
        for(int j=st;j<=i;j++){
            update(p[j].second);
        }
    }
    int res = n * 1ll * q[n] % mod;
    res = (res - answ + mod) % mod;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 26624