#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<tuple>
#include<sstream>
#include<functional>
#include<list>
#include<queue>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
typedef pair<ll, ll> p;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
using graph = vector<vector<ll>>;

const ll inf = (1LL<<31)-1;
const long long MOD = 1000000007;
const ll modd = 998244353;

template<typename T>
struct BIT {
private:
    vector<T> array;
    const int n;

public:
    BIT(int _n) :array(_n + 1, 0), n(_n) {};

    //1番目からi番目までの累積和
    T sum(int i) {
        T s = 0;
        while (i > 0) {
            s += array[i];
            i -= i & -i;//LSB減算
        }
        return s;
    }

    //[i,j]の要素の和
    T sum(int i, int j) {
        T ret_i = sum(i - 1);
        T ret_j = sum(j);
        return ret_j - ret_i;
    }

    //i番目に要素xを追加する
    void add(int i, T x) {
        while (i <= n) {
            array[i] += x;
            i += i & -i;//LSB加算
        }
    }
};

/* compress
    (X1,Y1),(X2,Y2)という二点で表されるもの（長方形や直線など）について、行か列の片方（X1とX2 or Y1とY2）を座標圧縮する（副作用）
    返り値: ソートされ重複要素を除いた値
    計算量: O(n log n)
*/
template <typename T>
vector<T> compress(vector<T>& C1, vector<T>& C2) {
    vector<T> vals, VALS;
    int N = (int)C1.size();
    for (int i = 0; i < N; i++) {
        for (T d = 0; d < 1; d++) {  // その位置と、一つ隣を確保(隣を確保しないと空白が埋まってしまうことがある)
            T tc1 = C1[i] + d;
            T tc2 = C2[i] + d;
            vals.push_back(tc1);
            VALS.push_back(tc2);
        }
    }
    // ソート
    sort(vals.begin(), vals.end());
    sort(VALS.begin(), VALS.end());
    // 隣り合う重複を削除(unique), 末端のゴミを削除(erase)
    vals.erase(unique(vals.begin(), vals.end()), vals.end());
    VALS.erase(unique(VALS.begin(), VALS.end()), VALS.end());
    for (int i = 0; i < N; i++) {
        C1[i] = lower_bound(vals.begin(), vals.end(), C1[i]) - vals.begin();
        C2[i] = lower_bound(VALS.begin(), VALS.end(), C2[i]) - VALS.begin();
    }
    return vals;
}

ll modpow(ll a, ll b, ll mod) {
    ll res = 1;
    while (b) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}


int main() {
    int n;
    ll ans = 0;
    cin >> n;
    vec v1, v2;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        v1.push_back(a);
        v2.push_back(b);
    }
    compress(v1, v2);
    vector<P> v(n);
    rep(i, n) {
        v[i] = P(v1[i], v2[i]);
    }
    sort(all(v));
    BIT<int> bit1(n), bit2(n);
    rep(i, n)bit2.add(i + 1, 1);
    rep(i, n) {
        bit2.add(v[i].second + 1, -1);
        ll a = bit1.sum(v[i].second);
        ll b = bit2.sum(v[i].second);
        ll c = modpow(2, n - 1, modd);
        ll d,e,f,g ;
        d = (modpow(2, bit1.sum(v[i].second),modd)-1)%modd;
        d = (d*(modpow(2, bit2.sum(v[i].second), modd)-1)) % modd;
        d=(d*(modpow(2,i-bit1.sum(v[i].second), modd)-1)) % modd;
        d=(d*(modpow(2,n-1-i- bit2.sum(v[i].second), modd)-1)) % modd;
        e = (modpow(2, bit1.sum(v[i].second), modd)) % modd;
        e = (e * (modpow(2, bit2.sum(v[i].second), modd) - 1)) % modd;
        e = (e * (modpow(2, i - bit1.sum(v[i].second), modd) - 1)) % modd;
        e = (e * (modpow(2, n - 1 - i - bit2.sum(v[i].second), modd))) % modd;
        f = (modpow(2, bit1.sum(v[i].second), modd) - 1) % modd;
        f = (f * (modpow(2, bit2.sum(v[i].second), modd))) % modd;
        f = (f * (modpow(2, i - bit1.sum(v[i].second), modd))) % modd;
        f = (f * (modpow(2, n - 1 - i - bit2.sum(v[i].second), modd) - 1)) % modd;
        g = (e + f - d) % modd;
        ans += (c+g);
        ans %= modd;
        bit1.add(v[i].second + 1, 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8024