#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
// ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
string s,t;
int N;
ll K;
vpii datas;
map<int,int> ch1,ch2;
vi datax,datay;
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
pii pos[SIZE];
ll left[SIZE],right[SIZE];
struct BIT
{
	int bit[SIZE];
	int n;//bit.n=N+2で初期化
	
	void add(int k,int x){//(k番目にxを足す) 1-index
		while(k<=n){
			bit[k]+=x;
			k=k+(k&-k);//一番右端
		}
	}

	int sum(int k){//kまでの和
		int ret=0;
		while(k>0){
			ret+=bit[k];
			k=k-(k&-k);//一番左端
		}
		return ret;
	}

	int sum(int a,int b){//a~bの和
		return sum(b)-sum(a-1);
	}

};
BIT bit;
int main(){
	cin>>N;
	rep(i,N){
		int x,y;
		cin>>x>>y;
		datas.pb(mp(x,y));
		datax.pb(x);
		datay.pb(y);
	}
	sort(all(datax));
	sort(all(datay));
	rep(i,N){
		ch1[datax[i]]=i;
		ch2[datay[i]]=i;
	}
	int Gr[214514];
	rep(i,N){
		int x=ch1[datas[i].first],y=ch2[datas[i].second];
		Gr[x]=y;
		//cout<<x<<" "<<y<<endl;
	}
	ll ans=0;
	bit.n=N+2;
	rep(i,N){
		int x=i,y=Gr[i];
		bit.add(y+1,1);
		int c=bit.sum(y+1)-1;
		int b=x-c;
		int d=y-c;
		int a=N-1-x-y+c;
		//cout<<x<<" "<<y<<endl;
		//cout<<a<<b<<c<<d<<endl;
		ans+=powMod(2,N,MOD);
		ans+=MOD-1;
		ans%=MOD;
		ll hoge=0;
		hoge+=powMod(2,a,MOD);
		hoge+=MOD-1;
		hoge%=MOD;
		hoge+=powMod(2,b,MOD);
		hoge+=MOD-1;
		hoge%=MOD;
		hoge+=powMod(2,c,MOD);
		hoge+=MOD-1;
		hoge%=MOD;
		hoge+=powMod(2,d,MOD);
		hoge+=MOD-1;
		hoge%=MOD;
		hoge+=(powMod(2,a,MOD)-1)*(powMod(2,b,MOD)-1);
		hoge+=MOD;
		hoge%=MOD;
		hoge+=(powMod(2,c,MOD)-1)*(powMod(2,b,MOD)-1);
		hoge+=MOD;
		hoge%=MOD;
		hoge+=(powMod(2,a,MOD)-1)*(powMod(2,d,MOD)-1);
		hoge+=MOD;
		hoge%=MOD;
		hoge+=(powMod(2,c,MOD)-1)*(powMod(2,d,MOD)-1);
		hoge+=MOD;
		hoge%=MOD;
		ans-=hoge;
		ans+=MOD;
		ans%=MOD;
	}

	cout<<ans<<endl;
	// a+b=N-y-1,a+d=N-x-1, c+b=x, c+d=y,

}





Measured memory_bytes: 23668