#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

template <int MOD>
struct ModInt {
    using lint = long long;
    using mint = ModInt<MOD>;

    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // assignment
    ModInt& operator=(const ModInt& x) {
        if (this != &x) { this->val = x.val; }
        return *this;
    }

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt operator~() const {
        // non-recursive extended euclidean algorithm
        int s = val, t = MOD;
        mint sx = 1, sy = 0, tx = 0, ty = 1;
        while (s % t != 0) {
            int div = s / t;
            s -= t * div;
            sx -= tx * div;
            sy -= ty * div;

            std::swap(s, t);
            std::swap(sx, tx);
            std::swap(sy, ty);
        }
        return mint(tx);
    }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= ~x; }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 998244353;
using mint = ModInt<MOD>;

template <class T, class Int>
T ipow(T b, Int n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < v.size(); ++i) rev[v[i]] = i;
    return rev;
}

template <class Data, class Operator>
class SegmentTree {
    using DataMerger = std::function<Data(Data, Data)>;
    using Applier = std::function<Data(Operator, Data)>;

private:
    int length;
    std::vector<Data> dat;
    Data dat_id;        // データの単位元
    DataMerger dmerge;  // データをマージする関数
    Applier app;        // データに作用素を適用する関数

    Data query(int ql, int qr, int nidx, int nl, int nr) {
        if (nr <= ql || qr <= nl) return dat_id;
        if (ql <= nl && nr <= qr) return dat[nidx];
        Data vl = query(ql, qr, nidx * 2, nl, (nl + nr) / 2);
        Data vr = query(ql, qr, nidx * 2 + 1, (nl + nr) / 2, nr);
        return dmerge(vl, vr);
    }

public:
    explicit SegmentTree(int N, Data dat_id, DataMerger dmerge, Applier app)
        : length(1), dat_id(dat_id), dmerge(dmerge), app(app) {
        while (length < N) length <<= 1;
        dat.assign(length * 2, dat_id);
    }

    // half-open interval [ql, qr)
    Data query(int ql, int qr) { return query(ql, qr, 1, 0, length); }

    void update(int idx, Operator e) {
        int nidx = idx + length;
        dat[nidx] = app(e, dat[nidx]);
        while (nidx > 0) {
            nidx >>= 1;
            dat[nidx] = dmerge(dat[nidx * 2], dat[nidx * 2 + 1]);
        }
    }
};

int main() {
    int n;
    std::cin >> n;
    std::vector<int> xs(n), ys(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> xs[i] >> ys[i];
    }

    std::vector<int> ps(n);
    {
        auto xss = xs, yss = ys;
        auto revx = compress(xss);
        auto revy = compress(yss);
        for (int i = 0; i < n; ++i) {
            ps[revx[xs[i]]] = revy[ys[i]];
        }
    }

    SegmentTree<int, int> seg(
        n, 0,
        [](int a, int b) { return a + b; },
        [](int e, int a) { return a + e; });

    std::vector<int> ld(n);
    for (int x = 0; x < n; ++x) {
        ld[x] = seg.query(0, ps[x]);
        seg.update(ps[x], 1);
    }

    mint ans = 0;
    for (int x = 0; x < n; ++x) {
        mint pat = ipow(mint(2), n) -
                   (ipow(mint(2), x) + ipow(mint(2), n - x - 1) +
                    ipow(mint(2), ps[x]) + ipow(mint(2), n - ps[x] - 1)) +
                   (ipow(mint(2), ld[x]) +
                    ipow(mint(2), x - ld[x]) +
                    ipow(mint(2), ps[x] - ld[x]) +
                    ipow(mint(2), n - x - ps[x] + ld[x] - 1)) -
                   1;

        ans += pat;
    }

    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 22912