#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)998244353
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int mypow(int x, int y) {
	if (!y)return 1;
	if (y % 2)return mypow(x, y - 1) * x % mod;
	int memo = mypow(x, y / 2);
	return memo * memo % mod;
}
class lazySegTree {
	int n, node[500010] = {}, lazy[500010] = {};
	bool clearf[500010] = {};
public:
	lazySegTree(int n_) {
		n = 1;
		while (n < n_)n *= 2;
	}
	void clear() {
		rep(i, 500010)node[i] = lazy[i] = clearf[i] = 0;
	}
	void eval(int k, int l, int r) {
		if (lazy[k] != 0) {
			node[k] += lazy[k];
			if (r - l > 1) {
				lazy[2 * k + 1] += lazy[k] / 2;
				lazy[2 * k + 2] += lazy[k] / 2;
			}
			lazy[k] = 0;
		}
	}
	void add(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		eval(k, l, r);
		if (b <= l || r <= a)return;
		if (a <= l && r <= b) {
			lazy[k] += (r - l) * x;
			eval(k, l, r);
		}
		else {
			add(a, b, x, 2 * k + 1, l, (l + r) / 2);
			add(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = node[2 * k + 1] + node[2 * k + 2];
		}
	}
	int getsum(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		eval(k, l, r);
		if (b <= l || r <= a)return 0;
		if (a <= l && r <= b)return node[k];
		int vl = getsum(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = getsum(a, b, 2 * k + 2, (l + r) / 2, r);
		return vl + vr;
	}
};
int n;
P points[200010];
int memo[200010][4];
lazySegTree s(200010);
signed main() {
	cin >> n;
	rep(i, n)cin >> points[i].first >> points[i].second;
	sort(points, points + n);

	map<int, int> zaatu;
	rep(i, n)zaatu[points[i].second] = 0;
	int cnt = 0;
	for (auto i = zaatu.begin(); i != zaatu.end(); i++) {
		(*i).second = cnt;
		cnt++;
	}
	rep(i, n)points[i].second = zaatu[points[i].second];

	rep(i, n) {
		s.add(points[i].second, points[i].second + 1, 1);
		memo[i][0] = s.getsum(0, points[i].second + 1) - 1;
		memo[i][1] = s.getsum(points[i].second, n) - 1;
	}
	s.clear();
	int ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		s.add(points[i].second, points[i].second + 1, 1);
		memo[i][2] = s.getsum(0, points[i].second + 1) - 1;
		memo[i][3] = s.getsum(points[i].second, n) - 1;
		ans += mypow(2, n) - 1;
		ans -= mypow(2, memo[i][0] + memo[i][1]);
		ans += mod;
		ans %= mod;
		ans -= mypow(2, memo[i][1] + memo[i][3]);
		ans += mod;
		ans %= mod;
		ans -= mypow(2, memo[i][2] + memo[i][3]);
		ans += mod;
		ans %= mod;
		ans -= mypow(2, memo[i][2] + memo[i][0]);
		ans += mod;
		ans %= mod;
		ans += mypow(2, memo[i][0]);
		ans %= mod;
		ans += mypow(2, memo[i][1]);
		ans %= mod;
		ans += mypow(2, memo[i][2]);
		ans %= mod;
		ans += mypow(2, memo[i][3]);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 30464