#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>

using namespace std;
using lint = int64_t;
using P = pair<int, int>;

#define rep(i, n) for (lint i = 0; i < (n); ++i)
#define rep1(i, n) for (lint i = 1; i < (n); ++i)
#define repn(i, a, b) for(lint i = (a); i < (b); ++i)
#define Rep(i, n) for (lint i = (n); i >= 0; --i)
#define All(vec) vec.begin(), vec.end()
#define cend printf("\n")

constexpr lint mod = 998'244'353LL;
//constexpr lint mod = 1000'000'007LL;
constexpr lint inf = 3LL * mod * mod;
const double Pi = 2.0 * acos(0.0);

template<class T> using prique     = priority_queue<T>;
template<class T> using prique_inv = priority_queue<T, vector<T>, greater<T>>;
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& rhs) { return is >> rhs.first >> rhs.second; }
template<class T, class U>inline ostream& operator<<(ostream& os, const pair<T, U>& rhs) { return os << rhs.first << " " << rhs.second << "\n"; }
template<class InputIterator> void arrin(InputIterator first, InputIterator last) { for (; first != last; ++first) cin >> (*first); }
template<class InputIterator> void arrout(InputIterator first, InputIterator last) {
	for (; first != last; ++first) {
		cout << (*first) << ((first + 1) != last ? " " : "\n");
	}
}

constexpr bool pri(lint x) { for (lint i = 2; i * i <= x; ++i) if (x % i == 0) return false; return 1 < x; }

lint fact[3000000];
void fact_init(lint n, lint m = mod) {
	if (3000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (m <= fact[i]) fact[i] %= m;
	}
}

lint modpow(lint x, lint n, lint m = mod) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) {
			res *= x;
			if (m <= res) res %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return res;
}

lint intpow(lint x, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res *= x;
		x *= x;
		n >>= 1;
	}
	return res;
}

lint comb(lint n, lint r, lint m = mod) {
	if (r == 0 || r == n) return 1;
	lint res = fact[n] * modpow(fact[n - r], m - 2, m) % m * modpow(fact[r], m - 2, m) % m;
	return res < 0 ? res + m : res;
}

map<lint, lint> factring(lint n) {
	map<lint, lint> res;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++res[i];
		}
	}
	if (n != 1) ++res[n];
	return res;
}

void coordinate_compression(vector<P>& vec) {
	map<int, int>mp_x, mp_y;
	for(const auto& [x, y] : vec) {
		mp_x[x]++;
		mp_y[y]++;
	}
	int cnt = 0;
	for (const auto& [key, unsed] : mp_x) {
		mp_x[key] = cnt;
		cnt++;
	}
	cnt = 0;
	for (const auto& [key, unused] : mp_y) {
		mp_y[key] = cnt;
		cnt++;
	}
	for(P& p: vec) {
		const auto& [x, y] = p;
		p = P(mp_x[x], mp_y[y]);
	}
	sort(All(vec));
}

template<class T>
class binary_indexed_tree {
private:

	int m_size;
	vector<T>m_vec;

public:

	binary_indexed_tree(int size)
		:m_size(size)
	{
		m_vec.resize(m_size);
	}

	void add(int a, T w) { for (int x = a; x <= m_size; x += (x & -x)) m_vec[x] += w; }

	T sum(int a) const {
		T res = T();
		for (int x = a; x > 0; x -= (x & -x)) res += m_vec[x];
		return res;
	}

};

int n;
int mem[2 * 100010][4];
lint ans;
lint pow2[2 * 100010];
int main() {

	cin >> n;

	pow2[0] = 1;
	rep1(i, n + 1) {
		pow2[i] = (2 * pow2[i - 1] % mod);
	}

	vector<P>v(n);
	arrin(All(v));

	coordinate_compression(v);

	rep(t, 2) {
		binary_indexed_tree<int>bit(n + 10);
		rep(i, n) {
			int y = v[i].second;
			int a = bit.sum(y), b = i - bit.sum(y + 1);
			if (t == 0) {
				mem[i][0] = a;
				mem[i][1] = b;
			}
			else {
				mem[n - i - 1][2] = a;
				mem[n - i - 1][3] = b;
			}
			bit.add(y + 1, 1);
		}
		reverse(All(v));
	}
	rep(i, n) {
		lint a = (pow2[mem[i][0]] + pow2[mem[i][3]] - 1) % mod;
		lint b = (pow2[mem[i][1]] + pow2[mem[i][2]] - 1) % mod;
		lint add = (pow2[n] - a * b) % mod;
		if (add < 0) add += mod;
		ans = (ans + add) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 28268