#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 998244353;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

template <typename T>
struct SegmentTree {
    int n;
    vector<T> data;
    T INITIAL_VALUE;

    //使うときは、この2つを適宜変更する
    static T merge(T x, T y);
    void updateNode(int k, T x);

    SegmentTree(int size, T initial_value) {
        n = 1;
        INITIAL_VALUE = initial_value;
        while (n < size) n *= 2;
        data.resize(2 * n - 1, INITIAL_VALUE);
    }

    SegmentTree(const vector<T>& v, T initial_value) {
        int size = v.size();
        n = 1;
        INITIAL_VALUE = initial_value;
        while (n < size) n *= 2;
        data.resize(2 * n - 1, INITIAL_VALUE);

        for (int i = 0; i < size; i++) data[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--) data[i] = merge(data[i * 2 + 1], data[i * 2 + 2]);
    }

    T getLeaf(int k) {
        return data[k + n - 1];
    }

    void update(int k, T x) {
        k += n - 1; //葉の節点
        updateNode(k, x);
        while (k > 0) {
            k = (k - 1) / 2;
            data[k] = merge(data[k * 2 + 1], data[k * 2 + 2]);
        }
    }

    //区間[a, b)に対するクエリに答える
    //k:節点番号, [l, r):節点に対応する区間
    T query(int a, int b, int k, int l, int r) {
        //[a, b)と[l, r)が交差しない場合
        if (r <= a || b <= l) return INITIAL_VALUE;
        //[a, b)が[l, r)を含む場合、節点の値
        if (a <= l && r <= b) return data[k];
        else {
            //二つの子をマージ
            T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return merge(vl, vr);
        }
    }

    //外から呼ぶ用
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }

    //非再帰版: バグってるかもしれないので定数倍高速化する時以外使わないで
    //区間[a, b)に対するクエリに答える
    T query_fast(int a, int b) {
        T vl = INITIAL_VALUE, vr = INITIAL_VALUE;
        for (int l = a + n, r = b + n; l != r; l >>= 1, r >>= 1) {
            if (l & 1) vl = merge(vl, data[l++ - 1]);
            if (r & 1) vr = merge(data[--r - 1], vr);
        }
        return merge(vl, vr);
    }
};

//使うときは以下2つを変更
//非可換の場合は順序に注意！！！
template <typename T>
T SegmentTree<T>::merge(T x, T y) {
    return x + y;
}

template <typename T>
void SegmentTree<T>::updateNode(int k, T x) {
    data[k] = x;
}

vector< vector<ll> > cnt_brute(vector<P>& v) {
    int n = v.size();
    vector< vector<ll> > cnt(n, vector<ll>(4, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j == i) continue;
            if (v[i].first == v[j].first) {
                if (v[i].second > v[j].second) {
                    cnt[i][0]++;
                    cnt[i][1]++;
                } else {
                    cnt[i][2]++;
                    cnt[i][3]++;
                }
            } else if (v[i].second == v[j].second) {
                if (v[i].first > v[j].first) {
                    cnt[i][0]++;
                    cnt[i][2]++;
                } else {
                    cnt[i][1]++;
                    cnt[i][3]++;
                }
            } else {
                int f1 = (v[i].first < v[j].first);
                int f2 = (v[i].second < v[j].second);
                cnt[i][f1 + f2 * 2]++;
            }
        }
    }
    return cnt;
}

vector<ll> pow2;

ll calc(ll x) {
    if (x <= 0) return 0;
    return (pow2[x] + MOD - 1) % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    vector<P> v;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        v.emplace_back(x, y);
    }
    sort(v.begin(), v.end());

    map<ll, vector<int> > memo;
    map<ll, int> min_id_x, max_id_x;

    for (int i = 0; i < n; i++) {
        memo[v[i].second].push_back(i);
        
        if (min_id_x.find(v[i].first) == min_id_x.end()) {
            min_id_x[v[i].first] = i;
            max_id_x[v[i].first] = i;
        } else {
            max_id_x[v[i].first] = i;
        }
    }

    vector< vector<int> > vs;
    for (auto& p : memo) {
        vs.push_back(p.second);
    }

    SegmentTree<ll> st(n, 0);
    vector< vector<ll> > cnt(n, vector<ll>(4, 0));
    for (vector<int>& is : vs) {
        for (int i : is) {
            st.update(i, 1);
        }

        for (int i : is) {
            ll x = v[i].first;
            int min_i = min_id_x[x];
            int max_i = max_id_x[x];
            
            cnt[i][0] = st.query_fast(0, max_i + 1) - 1;
            cnt[i][1] = st.query_fast(min_i, n) - 1;
        }
    }

    st = SegmentTree<ll>(n, 0);
    reverse(vs.begin(), vs.end());
    for (vector<int>& is : vs) {
        for (int i : is) {
            st.update(i, 1);
        }

        for (int i : is) {
            ll x = v[i].first;
            int min_i = min_id_x[x];
            int max_i = max_id_x[x];
            
            cnt[i][2] = st.query_fast(0, max_i + 1) - 1;
            cnt[i][3] = st.query_fast(min_i, n) - 1;
        }
    }

    pow2.resize(n, 1);
    for (int i = 1; i < n; i++) pow2[i] = pow2[i - 1] * 2 % MOD;
    ll pow2_1 = pow2[n - 1];
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 4; j++) {
            cnt[i][j] = calc(cnt[i][j]);
        }

        int mask1 = 2 + 4;
        int mask2 = 1 + 8;
        for (int j = 0; j < (1 << 4); j++) {
            if ((j & mask1) == mask1 || (j & mask2) == mask2) {
                ll hoge = 1;
                for (int k = 0; k < 4; k++) {
                    if (j & (1 << k)) {
                        (hoge *= cnt[i][k]) %= MOD;
                    }
                }
                (ans += hoge) %= MOD;
            }
        }

        (ans += pow2_1) %= MOD;
        /* 
        cerr << cnt[i][2] << " " << cnt[i][3] << endl;
        cerr << cnt[i][0] << " " << cnt[i][1] << endl;
        cerr << endl;*/
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 84840