#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <ll mod>
struct modular {
    ll value;
    modular(ll x = 0) {
        value = x % mod;
        if (value < 0) value += mod;
    }
    modular& operator+=(modular other) {
        if ((value += other.value) >= mod) value -= mod;
        return *this;
    }
    modular& operator-=(modular other) {
        if ((value -= other.value) < 0) value += mod;
        return *this;
    }
    modular& operator*=(modular other) {
        value = value * other.value % mod;
        return *this;
    }
    modular& operator/=(modular other) {
        ll a = 0, b = 1, c = other.value, m = mod;
        while (c != 0) {
            ll t = m / c;
            m -= t * c;
            swap(c, m);
            a -= t * b;
            swap(a, b);
        }
        a %= mod;
        if (a < 0) a += mod;
        value = value * a % mod;
        return *this;
    }
    modular& operator^=(modular other) {
        ll r = 1, x = value, n = other.value;
        while (n > 0) {
            if (n & 1) r = r * x % mod;
            x = x * x % mod;
            n >>= 1;
        }
        value = r;
        return *this;
    }
    modular operator+(modular rhs) {
        return modular(*this) += rhs;
    }
    modular operator-(modular rhs) {
        return modular(*this) -= rhs;
    }
    modular operator*(modular rhs) {
        return modular(*this) *= rhs;
    }
    modular operator/(modular rhs) {
        return modular(*this) /= rhs;
    }
    modular operator^(modular rhs) {
        return modular(*this) ^= rhs;
    }
    bool operator==(modular rhs) {
        return value == rhs.value;
    };
    bool operator!=(modular rhs) {
        return value != rhs.value;
    };
    bool operator<(modular rhs) {
        return value < rhs.value;
    }
};
template <ll mod>
string to_string(modular<mod> x) {
    return to_string(x.value);
}
template <ll mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream << x.value;
}
template <ll mod>
istream& operator>>(istream& stream, modular<mod>& x) {
    stream >> x.value;
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream;
}
const ll mod = 998244353;
using mint = modular<mod>;

vector<mint> fac, finv;
inline void cinit(int n) {
    fac.resize(n, 1);
    finv.resize(n, 1);
    for (int i = 2; i < n; i++) {
        fac[i] = fac[i - 1] * i;
        finv[i] = finv[i - 1] / i;
    }
}
inline mint C(int n, int k) {
    if (n < k || k < 0 || n < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
inline mint H(int n, int k) {
    return C(n + k - 1, k);
}

template <class T>
struct fenwick {
    vector<T> node;
    int n;

    fenwick(int _n)
        : n(_n) {
        node.resize(n);
    }

    void add(int x, T v) {
        while (x < n) {
            node[x] += v;
            x |= (x + 1);
        }
    }

    T get(int x) {
        T v = 0;
        while (x >= 0) {
            v += node[x];
            x = (x & (x + 1)) - 1;
        }
        return v;
    }

    T get(int a, int b) {
        return get(b) - get(a - 1);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end());
    vector<int> y(n);
    for (int i = 0; i < n; i++) {
        y[i] = p[i].second;
    }
    vector<int> tmp = y;
    sort(tmp.begin(), tmp.end());
    for (int i = 0; i < n; i++) {
        y[i] = lower_bound(tmp.begin(), tmp.end(), y[i]) - tmp.begin();
    }
    vector<mint> pw(n);
    pw[0] = 1;
    for (int i = 1; i < n; i++) {
        pw[i] = pw[i - 1] * (mint)2;
    }
    mint ans = pw[n - 1];
    ans *= n;
    fenwick<int> bt(n + 1);
    for (int i = 0; i < n; i++) {
        mint res = 0;
        int cnt = bt.get(y[i]);
        mint la = pw[cnt] - (mint)1;
        mint lb = pw[i - cnt] - (mint)1;
        mint ra = pw[y[i] - cnt];
        mint rb = pw[n - y[i] - i + cnt - 1];
        res += la * (pw[n - 1 - i] - ra);
        res += lb * (pw[n - 1 - i] - rb);
        res += la * lb * (pw[n - 1 - i] - (mint)1);
        bt.add(y[i], 1);
        debug(la, lb);
        debug(res);
        ans += res;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760