#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using dd = double;
using vdd = std::vector<dd>;
using vvdd = std::vector<vdd>;
using vvvdd = std::vector<vvdd>;

constexpr ll INF = 1LL << 60;
constexpr dd EPS = 1e-11;

typedef std::numeric_limits< double > dbl;

//cin,cout高速化のおまじない＋桁数指定
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;

#define REPS(i, S, E) for (ll i = (S); i <= (E); i++)
#define REP(i, N) REPS(i, 0, N-1)
#define DEPS(i, S, E) for (ll i = (E); i >= (S); i--)
#define DEP(i, N) DEPS(i, 0, N-1)
#define EACH(e, v) for (auto&& e : v)

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> inline T MaxE(vector<T>&v,ll S,ll E){T m=v[S]; REPS(i,S,E)chmax(m,v[i]); return m;}//v[S]～v[E]の最大値
template<class T> inline T MinE(vector<T>&v,ll S,ll E){T m=v[S]; REPS(i,S,E)chmin(m,v[i]); return m;}//v[S]～v[E]の最小値
template<class T> inline T MaxE(vector<T> &v, ll N) { return MaxE(v, 0, N - 1); } //先頭N個中の最大値
template<class T> inline T MinE(vector<T> &v, ll N) { return MinE(v, 0, N - 1); }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v, (ll)v.size()); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v, (ll)v.size()); }
template<class T> inline ll MaxI(vector<T>&v,ll S,ll E){ll m=S; REPS(i,S,E){if(v[i]>v[m])m=i;} return m;}
template<class T> inline ll MinI(vector<T>&v,ll S,ll E){ll m=S; REPS(i,S,E){if(v[i]<v[m])m=i;} return m;}
template<class T> inline ll MaxI(vector<T> &v, ll N) { return MaxI(v, 0, N - 1); }
template<class T> inline ll MinI(vector<T> &v, ll N) { return MinI(v, 0, N - 1); }
template<class T> inline ll MaxI(vector<T> &v) { return MaxI(v, (ll)v.size()); }
template<class T> inline ll MinI(vector<T> &v) { return MinI(v, (ll)v.size()); }
template<class T> inline T Sum(vector<T> &v, ll S, ll E){ T s=v[S]; REPS(i, S+1, E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v, ll N) { return Sum(v, 0, N - 1); }
template<class T> inline T Sum(vector<T> &v) { return Sum(v, v.size()); }

template<class T=ll> inline vector<T> cinv(ll N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
template<class T=ll, class S=ll> inline vector<pair<T, S>> cinv2(ll N){
	vector<pair<T, S>> v(N); REP(i,N){cin>>v[i].first>>v[i].second;} return move(v); }
template<class T=ll,class S=ll,class R=ll> inline vector<tuple<T, S, R>> cinv3(ll N){
	vector<tuple<T,S,R>> v(N); REP(i,N){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);} return move(v);}
template<class T> inline void coutv(vector<T> &v, char deli=' '){
	ll N=(ll)v.size(); REP(i,N){cout << v[i] << ((i==N-1)?'\n':deli);} }

constexpr ll MOD = 998244353LL;// (ll)(1e9 + 7);
template<int mod> struct Modll{
	ll val;
	Modll(ll v = 0): val(v %mod){ if (val < 0) val += mod; }
	Modll operator - () { return -val; }
	Modll operator + (const Modll &b) const { return val + b.val; }
	Modll operator - (const Modll &b) const { return val - b.val; }
	Modll operator * (const Modll &b) const { return val * b.val; }
	Modll operator / (const Modll &b) const { return Modll(*this) /= b; }
	Modll operator + (ll b) const { return *this + Modll(b); }
	Modll operator - (ll b) const { return *this - Modll(b); }
	Modll operator * (ll b) const { return *this * Modll(b); }
	friend Modll<mod> operator + (ll a, const Modll<mod> &b) { return b + a; }
	friend Modll<mod> operator - (ll a, const Modll<mod> &b) { return -b + a; }
	friend Modll<mod> operator * (ll a, const Modll<mod> &b) { return b * a; }
	Modll &operator += (const Modll &b) { val=(val+b.val)%mod; return *this; }
	Modll &operator -= (const Modll &b) { val=(val+mod-b.val)%mod; return *this; }
	Modll &operator *= (const Modll &b) { val=(val*b.val)%mod; return *this; }
	Modll &operator /= (const Modll &b) {
		ll c=b.val, d=mod, u=1, v=0;
		while (d){
			ll t = c / d;
			c -= t * d; swap(c, d);
			u -= t * v; swap(u, v);
		}
		val = val * u % mod;
		if (val < 0) val += mod;
		return *this;
	}
	Modll &operator += (ll b) { return *this += Modll(b); }
	Modll &operator -= (ll b) { return *this -= Modll(b); }
	Modll &operator *= (ll b) { return *this *= Modll(b); }
	Modll &operator /= (ll b) { return *this /= Modll(b); }
	bool operator == (const Modll &b) { return val == b.val; }
	bool operator != (const Modll &b) { return val != b.val; }
	bool operator == (ll b) { return *this == Modll(b); }
	bool operator != (ll b) { return *this != Modll(b); }
	friend bool operator == (ll a, const Modll<mod> &b) { return Modll<mod>(a) == b.val; }
	friend bool operator != (ll a, const Modll<mod> &b) { return Modll<mod>(a) != b.val; }
	friend ostream &operator << (ostream &os, const Modll<mod> &a) { return os << a.val; }
	friend istream &operator >> (istream &is, const Modll<mod> &a) { return is >> a.val; }
	Modll pow(ll n){
		if (n == 0) return 1;
		auto b = pow(n / 2);
		return (n%2 == 1) ? b*b*val : b*b;
	}
};
using mll = Modll<MOD>;


template<class T, class S> class SegmentTree{
private:
	vector<T> node;
	ll n;
	T e;
	function<T(T, T)> ope;
	function<T(T, S)> update;
public:
	SegmentTree(vector<T> &v, T e_, function<T(T, T)> ope_,
		function<T(T, S)> update_): e(e_), ope(ope_), update(update_) {
		for (n = 1; n < (ll)v.size(); n *= 2);
		node.resize(2*n-1, e);
		REP(i, (ll)v.size()) { node[i+n-1] = v[i]; }//初期化
		DEP(i, n-1) { node[i] = ope(node[2*i+1], node[2*i+2]); }//構築
	}
	SegmentTree(ll size, T e_, function<T(T, T)> ope_,
		function<T(T, T)> update_): e(e_), ope(ope_), update(update_) {
		for (n = 1; n < size; n *= 2);
		node.resize(2*n-1, e);
	}
	T Range(ll a, ll b) { return Range(a, b, 0, 0, n); }
	void Update(ll i, S x){
		i += n-1;
		node[i] = update(node[i], x);
		while (i>0){
			i=(i-1)/2;
			node[i] = ope(node[2*i+1], node[2*i+2]);
		}
	}
private:
	T Range(ll a, ll b, ll k, ll l, ll r){ //注目ノードk=[l,r)
		if (r<=a || b<=l) return e; //完全に外
		if (a<=l && r<=b) return node[k];//完全に含まれる
		return ope(Range(a, b, k*2+1, l, (l+r)/2), Range(a, b, k*2+2, (l+r)/2, r));
	}
};


void solve()
{
	ll N;
	cin >> N;
	auto xy = cinv2(N);
	
	std::sort(xy.begin(), xy.end());
	REP(i, N) xy[i].first = i;
	std::sort(xy.begin(), xy.end(),
		[](auto &a, auto &b) {return a.second < b.second; }
	);
	REP(i, N) xy[i].second = i;

	SegmentTree<ll, ll> upper(N, 0LL,
		[](ll a, ll b){return a+b; },
		[](ll a, ll b){return b; }
	);
	SegmentTree<ll, ll> lower(N, 0LL,
		[](ll a, ll b){return a+b; },
		[](ll a, ll b){return b; }
	);
	EACH(e, xy) upper.Update(e.first, 1);

	vector<mll> twoPow;
	twoPow.resize(N+1);
	twoPow[0] = 1;
	REPS(i, 1, N) twoPow[i] = twoPow[i-1] * 2;
	mll I = twoPow[N] - 1;


	mll ans = 0;
	REP(i, N){
		ll xx = xy[i].first;
		upper.Update(xx, 0);

		ll D = lower.Range(0, xx);
		ll B = lower.Range(xx+1, INF);
		ll C = upper.Range(0, xx);
		ll A = upper.Range(xx+1, INF);
		mll II = twoPow[A+C] + twoPow[C+D] + twoPow[B+D] + twoPow[A+B]
			- twoPow[A] - twoPow[B] - twoPow[C] - twoPow[D];
		ans += (I-II);

		lower.Update(xx, 1);
	}

	cout << ans << '\n';
}

int main(){
	solve();
	return 0;
}


Measured memory_bytes: 13184