#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>

#define int long long
//#define double long double

using namespace std;

const long long MOD = 998244353;

long long n;
long long x[500000];
long long y[500000];

long long inq(long long a, long long x)
{
    if (x == 0) return 1;
    long long l = inq(a, x / 2);
    if (x % 2) return l * l % MOD * a;
    return l * l % MOD;
}

struct SegTree{
    int v[(1 << 20)];
    private :
    void add(int p, int L, int R, int V)
    {
        if (p + 1 <= L || R <= p)
            return;
        if (L + 1 == R)
        {
            v[V]++;
            return;
        }
        long long M = (L + R) / 2;
        add(p, L, M, 2 * V + 1);
        add(p, M, R, 2 * V + 2);
        v[V] = v[2 * V + 1] + v[2 * V + 2];
    }
    long long summ(int l, int r, int L, int R, int V)
    {
        if (r <= L || R <= l)
            return 0;
        if (l <= L && R <= r)
            return v[V];
        int M = (L + R) / 2;
        return summ(l, r, L, M, 2 * V + 1) + summ(l, r, M, R, 2 * V + 2);
    }
    public :
    long long summ(int l, int r)
    {
        return summ(l, r, 0, n, 0);
    }
    void add(int p)
    {
        add(p, 0, n, 0);
    }
};

map<int, int> xx, yy;
vector<int> adds;
vector<int> dels;

void pro(vector<pair<int, int> > xy)
{
    //cout << "EEE" << endl << endl;
    sort(xy.begin(), xy.end());
    SegTree ST;
    fill(ST.v, ST.v + (1 << 20), 0);
    for (int i = 0; i < xy.size(); i++)
    {
        int x = xy[i].first;
        int j = i;
        while (j + 1 < xy.size() && xy[j + 1].first == x)
            j++;
        for (int k = i; k <= j; k++)
        {
            //cout << "EE " << ST.summ(0, n) << endl;
            dels.push_back(ST.summ(0, n));
            adds.push_back(ST.summ(0, xy[k].second));
        }
        for (int k = i; k <= j; k++)
        {
            ST.add(xy[k].second);
        }
        i = j;
    }
    return;
}

signed main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    long long ans = 0;
    vector<long long> xes, yes;
    for (int i = 0; i < n; i++)
    {
        xes.push_back(x[i]);
        yes.push_back(y[i]);
    }
    sort(xes.begin(), xes.end()); xes.resize(unique(xes.begin(), xes.end()) - xes.begin());
    sort(yes.begin(), yes.end()); yes.resize(unique(yes.begin(), yes.end()) - yes.begin());
    for (int i = 0; i < xes.size(); i++)
    {
        xx[xes[i]] = i;
    }
    for (int i = 0; i < yes.size(); i++)
    {
        yy[yes[i]] = i;
    }
    for (int i = 0; i < n; i++)
    {
        x[i] = xx[x[i]];
        y[i] = yy[y[i]];
    }
    vector<pair<int, int> > xy;
    for (int i = 0; i < n; i++)
    {
        xy.push_back({x[i], y[i]});
    }
    pro(xy);
    xy.resize(0);
    for (int i = 0; i < n; i++)
    {
        xy.push_back({n - 1 - x[i], y[i]});
        swap(xy[i].first, xy[i].second);
    }
    pro(xy);
    xy.resize(0);
    for (int i = 0; i < n; i++)
    {
        xy.push_back({n - 1 - x[i], n - 1 - y[i]});
    }
    pro(xy);
    xy.resize(0);
    for (int i = 0; i < n; i++)
    {
        xy.push_back({x[i], n - 1 - y[i]});
        swap(xy[i].first, xy[i].second);
    }
    pro(xy);
    xy.resize(0);
    for (int i = 0; i < n; i++)
        adds.push_back(n);
    for (int i = 0; i < n; i++)
        dels.push_back(0);
    for (int i = 0; i < adds.size(); i++)
        ans = (ans + inq(2, adds[i])) % MOD;
    for (int i = 0; i < dels.size(); i++)
        ans = (ans + MOD - inq(2, dels[i])) % MOD;

    cout << (ans) % MOD;
}


Measured memory_bytes: 65304