#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 998244353LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
struct BIT {
    vector<ll> bit;
    BIT(int n) { bit.resize(++n); }
    void add(int k, ll x) {
        for (++k; k < bit.size(); k += k & -k) {
            bit[k] += x;
        }
    }
    ll sum(int k) {
        ll res = 0;
        for (++k; k > 0; k -= k & -k) {
            res += bit[k];
        }
        return res;
    }
};
template <ll mod> struct modint {
    ll val;
    inline ll extgcd(ll a, ll b, ll &x, ll &y) {
        if (a < b) {
            return extgcd(b, a, y, x);
        }
        if (b == 0) {
            x = 1, y = 0;
            return a;
        }
        ll d = extgcd(b, a % b, y, x);
        y -= a / b * x;
        return d;
    }
    inline ll minv(ll k) {
        ll x = 0, y = 0;
        extgcd(k, mod, x, y);
        if (x < 0) {
            x += mod;
        } else if (x == mod) {
            x = 0;
        }
        return x;
    }
    constexpr modint() : val(0) {}
    constexpr modint(ll x) { val = (x + mod) % mod; }
    modint inv() { return modint(minv(val)); }
    modint operator+(const modint &to) const { return modint(val + to.val); }
    modint operator-(const modint &to) const { return modint(val - to.val); }
    modint operator*(const modint &to) const { return modint(val * to.val); }
    modint operator/(const modint &to) const {
        return modint(val * minv(to.val));
    }
    template <class T> explicit operator T() { return T(val); }
    template <typename T> modint operator+(const T &to) const {
        return modint(val + to);
    }
    template <typename T> modint operator-(const T &to) const {
        return modint(val - to);
    }
    template <typename T> modint operator*(const T &to) const {
        return modint(val * to);
    }
    template <typename T> modint operator/(const T &to) const {
        return modint(val * minv(to));
    }
    modint &operator++() { return *this = modint(val + 1); }
    modint &operator--() { return *this = modint(val - 1); }
    template <typename T> modint &operator+=(const T &to) {
        return *this = *this + to;
    }
    template <typename T> modint &operator-=(const T &to) {
        return *this = *this - to;
    }
    template <typename T> modint &operator*=(const T &to) {
        return *this = *this * to;
    }
    template <typename T> modint &operator/=(const T &to) {
        return *this = *this / to;
    }
    bool operator==(const modint &to) const { return val == to.val; }
    bool operator!=(const modint &to) const { return val != to.val; }
    bool operator>(const modint &to) const { return val > to.val; }
    bool operator>=(const modint &to) const { return val >= to.val; }
    bool operator<(const modint &to) const { return val < to.val; }
    bool operator<=(const modint &to) const { return val <= to.val; }
};
using mint = modint<MOD>;
inline mint mpow(mint x, ll n) {
    mint res = 1;
    while (n > 0) {
        if (n & 1) {
            res *= x;
        }
        x = x * x;
        n >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> v;
    vector<ll> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        v.push_back(P(y[i], x[i]));
    }
    sort(all(v));
    sort(all(x));
    BIT b1(n + 1), b2(n + 1);
    for (int i = 0; i < n; i++) {
        b2.add(i, 1);
    }
    mint ans = 0;
    for (int i = 0; i < n; i++) {
        int ix = lower_bound(all(x), v[i].second) - x.begin();
        b2.add(ix, -1);
        ll c1 = b1.sum(ix), c2 = b1.sum(n - 1) - b1.sum(ix), c3 = b2.sum(ix),
           c4 = b2.sum(n - 1) - b2.sum(ix);
        mint b = 2LL;
        mint to = mpow(b, n - 1);
        to += (mpow(b, c1) - 1LL) * (mpow(b, c4) - 1LL) * mpow(b, c2 + c3);
        to += (mpow(b, c2) - 1LL) * (mpow(b, c3) - 1LL) * mpow(b, c1 + c4);
        to -= (mpow(b, c1) - 1LL) * (mpow(b, c4) - 1LL) * (mpow(b, c2) - 1LL) *
              (mpow(b, c3) - 1LL);
        ans += to;
        b1.add(ix, 1);
    }
    cout << ans.val << endl;
}


Measured memory_bytes: 10348