#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 998244353;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// Binary Indexed Tree / Fenwick tree
// can calculate partial sum in O(logN)
// can update single datum in O(logN)
// lower_bound is binary search O(logN)
// 0-indexed!!!
template <typename T = int>
struct BinaryIndexedTree {
    int n;
    vector<T> bit;
    BinaryIndexedTree(int n_, T init = 0) : n(n_), bit(n_ + 1, init) {}
    BinaryIndexedTree(vector<T> init) : n(init.size() + 1), bit(init.size() + 1) {
        for (int i = 1; i < init.size() + 1; ++i) {
            bit[i] = init[i - 1];
        }
    }
    T sum(int i) {
        i++;
        T s = bit[0];
        for (int x = i; x > 0; x -= (x & -x))
            s += bit[x];
        return s;
    }
    void add(int i, T a) {
        i++;
        if (i == 0)
            return;
        for (int x = i; x <= n; x += (x & -x))
            bit[x] += a;
    }
    int lower_bound(int w) {
        w++;
        if (w <= 0)
            return 0;
        int x = 0, r = 1;
        while (r < n)
            r <<= 1;
        for (int k = r; k > 0; k >>= 1) {
            if (x + k <= n && bit[x + k] < w) {
                w -= bit[x + k];
                x += k;
            }
        }
        return x + 1;
    }
    T query(int l, int r) { return sum(r - 1) - sum(l - 1); }
};

// mod int struct
// original : https://github.com/beet-aizu/library/blob/master/mod/mint.cpp

struct mint {
    ll v;
    ll mod;
    mint() : v(0) {}
    mint(signed v, ll mod = MOD) : v(v), mod(mod) {}
    mint(ll t, ll mod = MOD) : mod(mod) {
        v = t % mod;
        if (v < 0)
            v += mod;
    }

    mint pow(ll k) {
        mint res(1), tmp(v);
        while (k) {
            if (k & 1)
                res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }

    static mint add_identity() { return mint(0); }
    static mint mul_identity() { return mint(1); }

    mint inv() { return pow(mod - 2); }

    mint &operator+=(mint a) {
        v += a.v;
        if (v >= MOD)
            v -= MOD;
        return *this;
    }
    mint &operator-=(mint a) {
        v += MOD - a.v;
        if (v >= MOD)
            v -= MOD;
        return *this;
    }
    mint &operator*=(mint a) {
        v = 1LL * v * a.v % MOD;
        return *this;
    }
    mint &operator/=(mint a) { return (*this) *= a.inv(); }

    mint operator+(mint a) const { return mint(v) += a; };
    mint operator-(mint a) const { return mint(v) -= a; };
    mint operator*(mint a) const { return mint(v) *= a; };
    mint operator/(mint a) const { return mint(v) /= a; };

    mint operator-() const { return v ? mint(MOD - v) : mint(v); }

    bool operator==(const mint a) const { return v == a.v; }
    bool operator!=(const mint a) const { return v != a.v; }
    bool operator<(const mint a) const { return v < a.v; }

    // find x s.t. a^x = b
    static ll log(ll a, ll b) {
        const ll sq = 40000;
        unordered_map<ll, ll> dp;
        dp.reserve(sq);
        mint res(1);
        for (int r = 0; r < sq; r++) {
            if (!dp.count(res.v))
                dp[res.v] = r;
            res *= a;
        }
        mint p = mint(a).inv().pow(sq);
        res = b;
        for (int q = 0; q <= MOD / sq + 1; q++) {
            if (dp.count(res.v)) {
                ll idx = q * sq + dp[res.v];
                if (idx > 0)
                    return idx;
            }
            res *= p;
        }
        assert(0);
        return ll(-1);
    }

    static mint comb(long long n, int k) {
        mint num(1), dom(1);
        for (int i = 0; i < k; i++) {
            num *= mint(n - i);
            dom *= mint(i + 1);
        }
        return num / dom;
    }
};
ostream &operator<<(ostream &os, mint m) {
    os << m.v;
    return os;
}

int main() {
    int n;
    cin >> n;
    vl x(n), y(n);
    vector<pll> xy(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        xy[i] = {x[i], y[i]};
    }
    sort(y.begin(), y.end());
    auto yidx = [&](ll yy) { return lower_bound(y.begin(), y.end(), yy) - y.begin(); };
    sort(xy.begin(), xy.end());
    BinaryIndexedTree<int> bitup(n);
    BinaryIndexedTree<int> bitdn(n);
    mint ret = 0; // mint(n).pow(2) + mint(n);
    vector<ll> upleft(n, 0);
    vector<ll> upright(n, 0);
    vector<ll> dnleft(n, 0);
    vector<ll> dnright(n, 0);
    for (int i = 0; i < xy.size(); ++i) {
        dnleft[i] = bitup.query(0, yidx(xy[i].second));
        upleft[i] = bitup.query(yidx(xy[i].second), n);
        bitup.add(yidx(xy[i].second), 1);
    }
    for (int i = xy.size() - 1; i >= 0; --i) {
        dnright[i] = bitdn.query(0, yidx(xy[i].second));
        upright[i] = bitdn.query(yidx(xy[i].second), n);
        bitdn.add(yidx(xy[i].second), 1);
    }
    for (int i = 0; i < n; ++i) {
        assert(1 + upleft[i] + upright[i] + dnleft[i] + dnright[i] == n);
        ret += mint(2).pow(n) - 1;
        ret -= mint(2).pow(upleft[i] + upright[i]) - 1;
        ret -= mint(2).pow(dnleft[i] + dnright[i]) - 1;
        ret -= mint(2).pow(upleft[i] + dnleft[i]) - 1;
        ret -= mint(2).pow(upright[i] + dnright[i]) - 1;
        ret += mint(2).pow(upleft[i]) - 1;
        ret += mint(2).pow(upright[i]) - 1;
        ret += mint(2).pow(dnleft[i]) - 1;
        ret += mint(2).pow(dnright[i]) - 1;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 14336