//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

template <int p>
struct Modint
{
    int value;

    Modint() : value(0) {}
    Modint(long x) : value(x >= 0 ? x % p : (p + x % p) % p) {}

    inline Modint &operator+=(const Modint &b)
    {
        if ((this->value += b.value) >= p)
            this->value -= p;
        return (*this);
    }
    inline Modint &operator-=(const Modint &b)
    {
        if ((this->value += p - b.value) >= p)
            this->value -= p;
        return (*this);
    }
    inline Modint &operator*=(const Modint &b)
    {
        this->value = (int)((1LL * this->value * b.value) % p);
        return (*this);
    }
    inline Modint &operator/=(const Modint &b)
    {
        (*this) *= b.inverse();
        return (*this);
    }

    Modint operator+(const Modint &b) const { return Modint(*this) += b; }
    Modint operator-(const Modint &b) const { return Modint(*this) -= b; }
    Modint operator*(const Modint &b) const { return Modint(*this) *= b; }
    Modint operator/(const Modint &b) const { return Modint(*this) /= b; }

    inline Modint &operator++(int) { return (*this) += 1; }
    inline Modint &operator--(int) { return (*this) -= 1; }

    inline bool operator==(const Modint &b) const
    {
        return this->value == b.value;
    }
    inline bool operator!=(const Modint &b) const
    {
        return this->value != b.value;
    }
    inline bool operator<(const Modint &b) const
    {
        return this->value < b.value;
    }
    inline bool operator<=(const Modint &b) const
    {
        return this->value <= b.value;
    }
    inline bool operator>(const Modint &b) const
    {
        return this->value > b.value;
    }
    inline bool operator>=(const Modint &b) const
    {
        return this->value >= b.value;
    }

    // requires that "this->value and p are co-prime"
    // a_i * v + a_(i+1) * p = r_i
    // r_i = r_(i+1) * q_(i+1) + r_(i+2)
    // q == 1 (i > 1)
    // reference: https://atcoder.jp/contests/agc026/submissions/2845729
    // (line:93)
    inline Modint inverse() const
    {
        assert(this->value != 0);
        int r0 = p, r1 = this->value, a0 = 0, a1 = 1;
        while (r1)
        {
            int q = r0 / r1;
            r0 -= q * r1;
            swap(r0, r1);
            a0 -= q * a1;
            swap(a0, a1);
        }
        return Modint(a0);
    }

    friend istream &operator>>(istream &is, Modint<p> &a)
    {
        long t;
        is >> t;
        a = Modint<p>(t);
        return is;
    }
    friend ostream &operator<<(ostream &os, const Modint<p> &a)
    {
        return os << a.value;
    }
};

/*
verified @ https://atcoder.jp/contests/abc034/submissions/4316971
*/

const int MOD = 998244353;

using Int = Modint<MOD>;

Int pow(Int e, long x)
{
    Int res = 1, tmp = e;
    while (x > 0)
    {
        if (x & 1)
            res *= tmp;
        tmp *= tmp;
        x >>= 1;
    }
    return res;
}

template <typename T>
struct BIT
{
    int N, K;
    vector<T> bit;

    BIT(int X)
    {
        bit = vector<T>(X + 1, 0);
        N = X + 1;
        K = pow(2, (int)(log(X) / log(2)));
    }

    void add(int idx, T w)
    {
        for (int x = idx; x <= N; x += x & -x)
        {
            bit[x] += w;
        }
    }

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

    int lb(T w)
    {
        int k = K, idx = 0;

        while (k > 0)
        {
            if (idx + k <= N && w > bit[idx + k])
            {
                w -= bit[idx + k];
                idx += k;
            }
            k >>= 1;
        }

        return idx + 1;
    }

    void chmax(int idx, T w)
    {
        for (int x = idx; x <= N; x += x & -x)
        {
            bit[x] = max(bit[x], w);
        }
    }

    T getmax(int idx)
    {
        T res = numeric_limits<T>::min();
        for (int x = idx; x > 0; x -= x & -x)
            res = max(res, bit[x]);
        return res;
    }
};

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<pair<int, int>> ps(n), xs(n), ys(n);
    for (int i = 0; i < n; i++)
    {
        cin >> ps[i].first >> ps[i].second;
        xs[i] = make_pair(ps[i].first, i);
        ys[i] = make_pair(ps[i].second, i);
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    for (int i = 0; i < n; i++)
    {
        ps[ys[i].second].second = i;
    }
    sort(ps.begin(), ps.end());
    Int ans = n;
    BIT<int> bit(n + 1);
    for (int i = 0; i < n; i++)
    {
        ans += pow(Int(2), n - 1) - 1;
        int y = ps[i].second;
        akari<int> cs(4);
        cs[0] = bit.sum(y + 1), cs[1] = i - cs[0];
        bit.add(y + 1, 1);
        cs[3] = y - cs[0], cs[2] = n - 1 - i - cs[3];
        for (int s = 1; s < 16; s++)
        {
            if (!((s & 0b1010) == 0b1010) && !((s & 0b0101) == 0b0101))
            {
                continue;
            }
            Int res = 1;
            for (int j = 0; j < 4; j++)
            {
                if (s >> j & 1)
                {
                    res *= pow(Int(2), cs[j]) - 1;
                }
            }
            //cout << bitset<4>(s) << ' ' << res << endl;
            ans += res;
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 7552