#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
const long long mod = 998244353;

class carr {
	int** c;
	int level;
public:
	carr(int n, int t = 0) {
		for (int i = 0; i < 30; i++) {
			if (1 << i >= n) {
				level = i + 1;
				break;
			}
		}
		c = new int*[level];
		for (int i = 0; i < level; i++) {
			c[i] = new int[1 << (level - 1 - i)];
			for (int j = 0; j < 1 << (level - 1 - i); j++) {
				if (i == 0) {
					c[0][j] = j < n ? t : 0;
				}
				else {
					c[i][j] = c[i - 1][j << 1] + c[i - 1][(j << 1) + 1];
				}
			}
		}
	}
	carr(int n, int *t) {
		for (int i = 0; i < 30; i++) {
			if (1 << i >= n) {
				level = i + 1;
				break;
			}
		}
		c = new int*[level];
		for (int i = 0; i < level; i++) {
			c[i] = new int[1 << (level - 1 - i)];
			for (int j = 0; j < 1 << (level - 1 - i); j++) {
				if (i == 0) {
					c[0][j] = j < n ? t[j] : 0;
				}
				else {
					c[i][j] = c[i - 1][j << 1] + c[i - 1][(j << 1) + 1];
				}
			}
		}
	}
	void cadd(int n, int a = 1) {
		for (int i = 0; i < level; i++) {
			c[i][n >> i] += a;
		}
	}
	void csub(int n, int a = 1) {
		for (int i = 0; i < level; i++) {
			c[i][n >> i] -= a;
		}
	}
	int prev(int n) {
		for (int i = 0; i < level; i++) {
			if (n&(1 << i) && c[i][(n >> i) - 1]) {
				int r = (n >> i) - 1;
				for (int j = i - 1; j >= 0; j--) {
					r <<= 1;
					if (c[j][r | 1])r |= 1;
				}
				return r;
			}
		}
		return -1;
	}
	int next(int n) {
		for (int i = 0; i < level; i++) {
			if ((n&(1 << i)) == 0 && c[i][(n >> i) + 1]) {
				int r = (n >> i) + 1;
				for (int j = i - 1; j >= 0; j--) {
					r <<= 1;
					if (c[j][r] == 0)r |= 1;
				}
				return r;
			}
		}
		return -1;
	}
	int count_before(int n) {
		int res = 0;
		for (int i = 0; i < level; i++) {
			if (n&(1 << i)) {
				res += c[i][(n >> i) - 1];
			}
		}
		return res;
	}
	int count_after(int n) {
		return c[level - 1][0] - count_before(n) - c[0][n];
	}
	int nth(int n) {
		if (n > c[level - 1][0])return -1;
		int r = 0;
		for (int i = level - 1; i >= 0; i--) {
			r <<= 1;
			if (c[i][r] > n) {
				r |= 1;
			}
		}
		return r;
	}
};

struct  pos
{
	int x, y, ix, iy;
	bool operator<(const pos& o)const {
		return x < o.x;
	}
};

struct py
{
	pos*p;
	bool operator<(const py& o)const {
		return p->y < o.p->y;
	}
};

int main() {
	int N;
	scanf("%d", &N);
	pos *p = new pos[N];
	py*p_y = new py[N];
	long long *pow2 = new long long[N + 1];
	long long p2 = 1;
	for (int i = 0; i < N; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		p[i].x = x;
		p[i].y = y;
		p_y[i].p = p + i;
		pow2[i] = p2;
		p2 *= 2;
		p2 %= mod;
	}
	pow2[N] = p2;
	std::sort(p, p + N);
	std::sort(p_y, p_y + N);
	for (int i = 0; i < N; i++) {
		p[i].ix = i;
		p_y[i].p->iy = i;
	}
	carr l(N, 0), r(N, 1);
	long long res = 0;
	for (int i = 0; i < N; i++) {
		int d1 = r.count_after(p[i].iy);
		int d2 = r.count_before(p[i].iy);
		int d3 = l.count_before(p[i].iy);
		int d4 = l.count_after(p[i].iy);
		res += pow2[N] + mod - ((pow2[d1] - 1)*((pow2[d2] - 1) + (pow2[d4] - 1) + 1) + (pow2[d2] - 1)*pow2[d3] + pow2[d3] * pow2[d4]) % mod;
		res %= mod;
		l.cadd(p[i].iy);
		r.csub(p[i].iy);
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 10624