#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;
struct SegT2d {
	int H, W;
	vector< vector< int > > dat;
	SegT2d() {}
	SegT2d(vector< vector< int > > &f) {
		H = W = 1;
		while (H < (int)f.size())
			H <<= 1;
		while (W < (int)f[0].size())
			W <<= 1;
		dat.assign(2 * H - 1, vector< int >(2 * W - 1, 0));
		init(f);
	}
	void init(vector< vector< int > > &f) {
		for (int i = 0; i < (int)f.size(); i++)
			for (int j = 0; j < (int)f[0].size(); j++)
				dat[i + H - 1][j + W - 1] = f[i][j];
		for (int i = 2 * H - 2; i > H - 2; i--)
			for (int j = W - 2; j >= 0; j--)
				dat[i][j] = (dat[i][2 * j + 1] + dat[i][2 * j + 2]);
		for (int i = H - 2; i >= 0; i--)
			for (int j = 0; j < 2 * W - 1; j++)
				dat[i][j] = (dat[2 * i + 1][j] + dat[2 * i + 2][j]);
	}
	int get(int li, int lj, int ri, int rj) { return get_h(li, lj, ri, rj, 0, H, 0); }
	int get_h(int li, int lj, int ri, int rj, int si, int ti, int k) {
		if (ri <= si or ti <= li)
			return 0;
		if (li <= si and ti <= ri)
			return get_w(lj, rj, 0, W, k, 0);
		const int mi = (si + ti) / 2;
		return (get_h(li, lj, ri, rj, si, mi, 2 * k + 1) + get_h(li, lj, ri, rj, mi, ti, 2 * k + 2));
	}
	int get_w(int lj, int rj, int sj, int tj, int i, int k) {
		if (rj <= sj or tj <= lj)
			return 0;
		if (lj <= sj and tj <= rj)
			return dat[i][k];
		const int mj = (sj + tj) / 2;
		return (get_w(lj, rj, sj, mj, i, 2 * k + 1) + get_w(lj, rj, mj, tj, i, 2 * k + 2));
	}
};
int compress(vector< int > &x) {
	vector< int > xs = x;
	int N = x.size();
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	for (int i = 0; i < N; i++) {
		x[i] = lower_bound(xs.begin(), xs.end(), x[i]) - xs.begin();
	}
	return xs.size();
}
ll gcd(ll a, ll b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}
ll extgcd(ll a, ll b, ll &x, ll &y) {
	int d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1;
		y = 0;
	}
	return d;
}
ll factorial(ll x) {
	if (x == 1)
		return 1;
	else
		return x * factorial(x - 1);
}
ll Mfactorial(ll x, ll m) {
	ll ret = 1;
	for (ll i = 1; i <= x; i++) {
		ret *= i;
		ret %= m;
	}
	return ret;
}
vector< int > MfactTable(int n, int m) {
	vector< int > ret(n + 1);
	ret[0] = 1;
	int tmp = 1;
	for (int i = 1; i <= n; i++) {
		tmp *= i;
		tmp %= m;
		ret[i] = tmp;
	}
	return ret;
}
int Minverse(int a, int m) {
	int x, y;
	extgcd(a, m, x, y);
	return (m + x % m) % m;
}
int McombSmall(int n, int k, int m) {
	//O(n)
	int ret = Mfactorial(n, m);
	ret *= Minverse(Mfactorial(k, m), m);
	ret %= m;
	ret *= Minverse(Mfactorial(n - k, m), m);
	return ret % m;
}
int McombFromFactTable(vector< int > &T, int n, int k, int m) {
	if (k > n)
		return 0;
	int ret = T[n];
	ret *= Minverse(T[k], m);
	ret %= m;
	ret *= Minverse(T[n - k], m);
	return ret % m;
}
ll pow(ll x, int n) {
	if (n == 0)
		return 1;
	ll ret = (n & 1) ? x : 1;
	ll a = pow(x, n / 2);
	return ret * a * a;
}
ll Mpow(ll x, int n, int m) {
	if (n == 0)
		return 1;
	ll ret = (n & 1) ? x : 1;
	ll a = Mpow(x, n / 2, m);
	return (((ret * a) % m) * a) % m;
}
vector< vector< int > > combTable(int N) {
	vector< vector< int > > ret(N + 1, vector< int >(N + 1));
	for (int i = 0; i <= N; i++)
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				ret[i][j] = 1;
			else
				ret[i][j] = ret[i - 1][j - 1] + ret[i - 1][j];
		}
	return ret;
}
int countNmodPisQlr(int l, int r, int P, int Q) {
	//r>=l>=0
	return (r - Q + P) / P - (l - Q + P - 1) / P;
}
struct BIT {
	vector< int > container;
	BIT(int n) {
		container = vector< int >(n + 1, 0);
	}
	void add(int i, int x) {
		if (i > container.size())
			return;
		container[i] += x;
		add(i + (i & -i), x);
	}
	int sum(int i) { //[1,i]
		if (i == 0)
			return 0;
		return container[i] + sum(i - (i & -i));
	}
	int sum(int l, int r) { //[l,r)
		return sum(r - 1) - sum(l - 1);
	}
};
int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > x(N), y(N);
	rep(i, N) cin >> x[i] >> y[i];
	compress(x);
	compress(y);
	//cout << x << y;
	//vector< vector< int > > A(N, vector< int >(N, 0));
	//rep(i, N) A[x[i]][y[i]] = 1;
	//SegT2d st(A);
	vector< pii > P(N);
	rep(i, N) {
		P[i].first = x[i];
		P[i].second = y[i];
	}
	sort(P.begin(), P.end());
	int ans = (Mpow(2, N, MOD2) - 1) * N;
	vector< int > t = MfactTable(N + 10, MOD2);
	BIT bt(N), bt2(N);
	rep(i, N) bt2.add(i + 1, 1);
	rep(i, N) {
		bt2.add(P[i].second + 1, -1);
		int l = bt.sum(1, N + 1);
		int r = N - l - 1;
		int u = bt.sum(P[i].second + 1, N + 1) + bt2.sum(P[i].second + 1, N + 1);
		int d = N - u - 1;
		int tmp = 0;
		(tmp += Mpow(2, l, MOD2) - 1) %= MOD2;
		(tmp += Mpow(2, r, MOD2) - 1) %= MOD2;
		(tmp += Mpow(2, u, MOD2) - 1) %= MOD2;
		(tmp += Mpow(2, d, MOD2) - 1) %= MOD2;
		int lu = bt.sum(P[i].second + 1, N + 1);
		int ld = bt.sum(1, P[i].second + 1);
		int ru = bt2.sum(P[i].second + 1, N + 1);
		int rd = bt2.sum(1, P[i].second + 1);
		(tmp -= Mpow(2, lu, MOD2) - 1) %= MOD2;
		(tmp -= Mpow(2, ld, MOD2) - 1) %= MOD2;
		(tmp -= Mpow(2, ru, MOD2) - 1) %= MOD2;
		(tmp -= Mpow(2, rd, MOD2) - 1) %= MOD2;
		ans = (ans - tmp + MOD2) % MOD2;
		bt.add(P[i].second + 1, 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13160