#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

struct RMQ
{
private:
    int N;
    vector<ll> node;
    ll e;

public:
    RMQ() {}
    RMQ(ll e) : e(e) {}
    void __init__(int sz)
    {
        N = 1;
        while (N < sz)
            N *= 2;
        node.resize(2 * N - 1, e);
    }
    void build(vector<ll> &v)
    {
        int sz = int(v.size());
        __init__(sz);
        rep(i, sz)
        {
            node[i + N - 1] = v[i];
        }
        for (int i = N - 2; i >= 0; i--)
        {
            node[i] = (node[i * 2 + 1] + node[i * 2 + 2]);
        }
    }
    void update(int k, ll x)
    {
        k += N - 1;
        node[k] = x;
        while (k > 0)
        {
            k = (k - 1) / 2;
            node[k] = (node[2 * k + 1] + node[2 * k + 2]);
        }
    }
    void renew(int b, int e, ll x)
    {
        renew(b, e, 0, 0, N, x);
        return;
    }
    void renew(int b, int e, int k, int l, int r, ll x)
    {
        if (e <= 0 || b >= N)
            return;
        if (k > 0)
        {
            node[k] = (node[k] + node[(k - 1) / 2]);
        }
        if (r < b || e < l)
            return;
        if (b <= l && r <= e)
        {
            node[k] = (node[k] + (r - l) * x);
            return;
        }
        else if (k < N - 1)
        {
            renew(b, e, 2 * k + 1, l, (l + r) / 2, x);
            renew(b, e, 2 * k + 2, (l + r) / 2, r, x);
            return;
        }
        return;
    }

    ll get(int i)
    {
        int k = i + N - 1;
        ll res = node[k];
        while (k > 0)
        {
            k = (k - 1) / 2;
            res = (res + node[k]);
        }
        return res;
    }
    ll query(int a, int b) { return query(a, b, 0, 0, N); }
    ll query(int a, int b, int k, int l, int r)
    {
        if (b <= l || r <= a)
            return e;
        if (a <= l && r <= b)
            return node[k];
        ll vl, vr;
        vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return (vl + vr);
    }
    void recalc()
    {
        rep(k, N - 1)
        {
            node[2 * k + 1] = (node[2 * k * 1] + node[k]);
            node[2 * k + 2] = (node[2 * k * 2] + node[k]);
        }
    }
    ll show_one(int i)
    {
        return node[i + N - 1];
    }
    void show()
    {
        rep(i, N) cout << node[i] << " ";
        cout << endl;
        return;
    }
};

const ll MOD = 998244353;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    set<ll> xapp, yapp;
    vector<pll> pnt(n);
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        xapp.insert(x);
        yapp.insert(y);
        pnt[i] = mp(x, y);
    }
    map<ll, ll> xidx, yidx;
    ll xnum = 0, ynum = 0;
    for (auto x : xapp)
    {
        xidx[x] = xnum;
        xnum++;
    }
    for (auto y : yapp)
    {
        yidx[y] = ynum;
        ynum++;
    }
    vvll pcnt(n, vll(4, 0));
    vector<pll> yline(ynum);
    rep(i, n)
    {
        ll x = xidx[pnt[i].F], y = yidx[pnt[i].S];
        yline[y] = mp(x, i);
    }
    RMQ ygrt(0);
    ygrt.__init__(xnum);
    rep(y,ynum){
        ll x = yline[y].F, idx = yline[y].S;
        pcnt[idx][0] = ygrt.query(0, x);
        pcnt[idx][1] = ygrt.query(x + 1, xnum);
        ygrt.update(x, 1);
    }
    RMQ yless(0);
    yless.__init__(xnum);
    repr(y,ynum-1,-1)
    {
        ll x = yline[y].F, idx = yline[y].S;
        pcnt[idx][2] = yless.query(0, x);
        pcnt[idx][3] = yless.query(x + 1, xnum);
        yless.update(x, 1);
    }
    vll two(n + 1);
    two[0] = 1;
    rep(i,n){
        two[i + 1] = (two[i] * 2) % MOD;
    }
    ll ans = 0;
    rep(i,n){
        ans = (ans + two[n-1]) % MOD;
        rep(p0,2){
            rep(p1,2){
                rep(p2,2){
                    rep(p3,2)
                    {
                        if ((p0 * pcnt[i][0]) + (p1 * pcnt[i][1]) == 0)
                            continue;
                        if ((p1 * pcnt[i][1]) + (p3 * pcnt[i][3]) == 0)
                            continue;
                        if ((p2 * pcnt[i][2]) + (p0 * pcnt[i][0]) == 0)
                            continue;
                        if ((p2 * pcnt[i][2]) + (p3 * pcnt[i][3]) == 0)
                            continue;
                        ll res = 1;
                        if (p0)
                            res = (res * (two[pcnt[i][0]]-1)) % MOD;
                        if (p1)
                            res = (res * (two[pcnt[i][1]]-1)) % MOD;
                        if (p2)
                            res = (res * (two[pcnt[i][2]]-1)) % MOD;
                        if (p3)
                            res = (res * (two[pcnt[i][3]]-1)) % MOD;
                        ans = (ans + res) % MOD;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 74112