#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
	if (a > b) {
		a = b;
	}
}
template<class T> inline void chmax(T& a, T b) {
	if (a < b) {
		a = b;
	}
}

const int MOD = 998244353;
class mint {
	ll x;
public:
	mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
	
	mint operator -() const {
		return mint(-x);
	}
	
	mint &operator +=(const mint &a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}

	mint &operator -=(const mint &a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}

	mint &operator *=(const mint &a) {
		(x *= a.x) %= MOD;
		return *this;
	}

	mint operator +(const mint &a) const {
		mint res(*this);
		return res += a;
	}

	mint operator-(const mint &a) const {
		mint res(*this);
		return res -= a;
	}

	mint operator *(const mint &a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(MOD - 2);
	}

	mint &operator /=(const mint &a) {
		return (*this) *= a.inv();
	}

	mint operator /(const mint &a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream &operator<<(ostream& os, const mint &m) {
		os << m.x;
		return os;
	}
};

vector<ll> comp(vector<ll> &a) {
	ll n = a.size();
	map<ll, ll> comp;
	Rep (i, n) comp[a[i]] = 0;
	ll tmp = 0;
	for (auto &e : comp) {
		e.second = tmp;
		tmp++;
	}
	vector<ll> b;
	Rep (i, n) {
		b.emplace_back(comp[a[i]]);
	}
	return b;
}

template <class T>
class SegTree {
	int n;
	vector<T> data;
	T def;
	function<T(T, T)> operation;
	function<T(T, T)> update;

	T _query(int a, int b, int k, int l, int r) {
		if (r <= a or b <= l) return def;
		if (a <= l and r <= b) return data[k];
		else {
			T c1 = _query(a, b, 2*k+1, l, (l+r)/2);
			T c2 = _query(a, b, 2*k+2, (l+r)/2, r);
			return operation(c1, c2);
		}
	}

	public:
	SegTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n <= _n) {
			n *= 2;
		}
		data = vector<T>(2*n-1, def);
	}

	void change(int i, T x) {
		i += n-1;
		data[i] = update(data[i], x);
		while (i > 0) {
			i = (i-1) / 2;
			data[i] = operation(data[i*2+1], data[i*2+2]);
		}
	}

	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}

	T operator[] (int i) {
		return data[i+n-1];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N;
	cin >> N;
	vec x(N), y(N);
	Rep (i, N) {
		cin >> x[i] >> y[i];
	}

	x = comp(x);
	y = comp(y);

	vector<pair<ll, ll>> co(N);
	Rep (i, N) {
		co[i] = {x[i], y[i]};
	}

	sort(co.begin(), co.end());

	SegTree<ll> stl(N, 0, [](ll a, ll b) {return a+b;}, [](ll a, ll b) {return b;});
	SegTree<ll> str(N, 0, [](ll a, ll b) {return a+b;}, [](ll a, ll b) {return b;});

	Rep (i, N) {
		str.change(i, 1);
	}

	mint ans(0);

	Rep (i, N) {
		ll y = co[i].second;
		str.change(y, 0);
		ll a = stl.query(0, y);
		ll b = stl.query(y+1, N);
		ll c = str.query(0, y);
		ll d = str.query(y+1, N);

		// cout << a << " " << b << " " << c << " " << d << "\n";

		// 0
		ans += 1;
		// 1
		ans += mint(2).pow(a)+mint(-1);
		ans += mint(2).pow(b)+mint(-1);
		ans += mint(2).pow(c)+mint(-1);
		ans += mint(2).pow(d)+mint(-1);
		// 2
		ans += (mint(2).pow(a)+mint(-1)) * (mint(2).pow(b)+mint(-1));
		ans += (mint(2).pow(b)+mint(-1)) * (mint(2).pow(d)+mint(-1));
		ans += (mint(2).pow(d)+mint(-1)) * (mint(2).pow(c)+mint(-1));
		ans += (mint(2).pow(c)+mint(-1)) * (mint(2).pow(a)+mint(-1));
		ans += mint(2) * (mint(2).pow(a)+mint(-1)) * (mint(2).pow(d)+mint(-1));
		ans += mint(2) * (mint(2).pow(b)+mint(-1)) * (mint(2).pow(c)+mint(-1));
		// 3
		mint A = mint(2).pow(a)+mint(-1);
		mint B = mint(2).pow(b)+mint(-1);
		mint C = mint(2).pow(c)+mint(-1);
		mint D = mint(2).pow(d)+mint(-1);
		
		ans += mint(2) * (B*C*D + C*D*A + D*A*B + A*B*C);

		ans += mint(2) * A*B*C*D;

		stl.change(y, 1);
	}

	cout << ans << endl;
}

Measured memory_bytes: 19540