#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 998244353;

template <int MOD = 1000000007>
struct Mint {
    int x;

    Mint() : x(0) {}
    Mint(long long t) {
        x = t % MOD;
        if (x < 0) x += MOD;
    }

    Mint pow(int n) {
        Mint res(1), t(x);
        while (n > 0) {
            if (n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        int a = x, b = MOD, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint &operator+=(Mint a) {
        x += a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator-=(Mint a) {
        x += MOD - a.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }

    Mint &operator*=(Mint a) {
        x = int(1LL * x * a.x % MOD);
        return *this;
    }

    Mint &operator/=(Mint a) {
        return (*this) *= a.inv();
    }

    Mint operator+(Mint a) const {
        return Mint(x) += a;
    }
    Mint operator-(Mint a) const {
        return Mint(x) -= a;
    }
    Mint operator*(Mint a) const {
        return Mint(x) *= a;
    }
    Mint operator/(Mint a) const {
        return Mint(x) /= a;
    }

    Mint operator-() const {
        return Mint(-x);
    }

    bool operator==(const Mint a) {
        return x == a.x;
    }
    bool operator!=(const Mint a) {
        return x != a.x;
    }
    bool operator<(const Mint a) {
        return x < a.x;
    }

    friend ostream &operator<<(ostream &os, const Mint &a) {
        return os << a.x;
    }

    friend istream &operator>>(istream &is, Mint &a) {
        int t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

template <typename T>
struct BIT {
    int n;
    vector<T> dat;

    BIT(int n) : n(n), dat(n + 1, 0) {}

    T sum(int idx) {
        T res(0);
        for (int i = idx; i > 0; i -= i & -i) res += dat[i];
        return res;
    }

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

    void add(int idx, T x) {
        if (idx == 0) return;
        for (int i = idx; i <= n; i += i & -i) dat[i] += x;
    }
    
    int lower_bound(T x) {
        if (x <= 0) return T(0);
        int res = 0, r = 1;
        while (r < n) r <<= 1;
        for (; r > 0; r >>= 1) {
            if (res + r <= n && dat[res + r] < x) {
                x -= dat[res + r];
                res += r;
            }
        }
        return res + 1;
    }

    T sum0(int idx) {
        return sum(idx + 1);
    }

    T sum0(int l, int r) {
        return sum(r) - sum(l);
    }

    void add0(int idx, T x) {
        add(idx + 1, x);
    }
};

template <typename T>
vector<T> compress(vector<T> vec) {
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

template <typename T>
map<T, int> dict(vector<T>& vec) {
    map<T, int> res;
    for (int i = 0; i < (int)vec.size(); i++) {
        res[vec[i]] = i;
    }
    return res;
}

signed main() {
    int n;
    cin >> n;
    vector<int> y;
    vector<pair<int, int>> v(n);
    rep(i, n) {
        cin >> v[i].first >> v[i].second;
        y.emplace_back(v[i].second);
    }
    auto c = compress(y);
    auto d = dict(c);
    sort(ALL(v));
    BIT<int> bitu(n), bitd(n);
    rep(i, n){
        bitu.add0(d[v[i].second], 1);
    }
    Mint<MOD> ans = 0;
    rep(i, n) {
        int A, B, C, D;
        A = bitu.sum0(d[v[i].second] + 1, n);
        B = bitu.sum0(0, d[v[i].second]);
        C = bitd.sum0(0, d[v[i].second]);
        D = bitd.sum0(d[v[i].second] + 1, n);
        ans += Mint<MOD>(2).pow(n - 1);
        ans += (Mint<MOD>(2).pow(A) - 1) * (Mint<MOD>(2).pow(C) - 1) *
               Mint<MOD>(2).pow(B) * Mint<MOD>(2).pow(D);
        ans += (Mint<MOD>(2).pow(B) - 1) * (Mint<MOD>(2).pow(D) - 1) *
               Mint<MOD>(2).pow(A) * Mint<MOD>(2).pow(C);
        ans -= (Mint<MOD>(2).pow(A) - 1) * (Mint<MOD>(2).pow(C) - 1) *
               (Mint<MOD>(2).pow(B) - 1) * (Mint<MOD>(2).pow(D) - 1);
        bitd.add0(d[v[i].second], 1);
        bitu.add0(d[v[i].second], -1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17456