#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds ;
using namespace std ;
 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set ;


const long long mod = 998244353 ;
const int MAX = 2e5 + 10 ;

int arr[MAX] ;
int n ;
long long P[MAX] ;
long long smaller1[MAX] , smaller2[MAX] , larger1[MAX] , larger2[MAX] ;

vector< pair<int , int> >vp ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	P[0] = 1ll ;
	for(int i = 1 ; i < MAX ; ++i)
		P[i] = (P[i-1] * 2ll) % mod ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		vp.emplace_back(x , y) ;
	}
	sort(vp.begin() , vp.end()) ;
	ordered_set s1 , s2 ;
	for(int i = n-1 ; i >= 0 ; --i)
	{
		smaller2[i] = s2.order_of_key(vp[i].second) ;
		larger2[i] = n-i-1 - smaller2[i] ;
		s2.insert(vp[i].second) ;
	}
	long long ans = 0ll , x , y , z , a , b , c ;
	for(int i = 0 ; i < n ; ++i)
	{
		smaller1[i]= s1.order_of_key(vp[i].second) ;
		larger1[i] = i - smaller1[i] ;
		s1.insert(vp[i].second) ;
		// Take current number
		x = 1ll ;
		y = P[n-1] % mod ;
		z = (x * y) % mod ;
		ans = (ans + z) % mod ;
		// Take smaller y from prev numbers , larger y from next numbers
		x = (P[smaller1[i]] - 1ll + mod) % mod ;
		y = (P[larger2[i]] - 1ll + mod) % mod ;
		z = (x * y) % mod ;
		ans = (ans + z) % mod ;
 		// Take smaller y from next numbers, larger y from prev numbers
		x = (P[smaller2[i]] - 1ll + mod) % mod ;
		y = (P[larger1[i]] - 1ll + mod) % mod ;
		z = (x * y) % mod ;
		ans = (ans + z) % mod ;
		// Take Both smaller and greater y from prev numbers and smaller numbers from next numbers
		x = (P[smaller1[i]] - 1ll + mod) % mod ;
		y = (P[larger1[i]] - 1ll + mod) % mod ;
		z = (x * y) % mod ;
		b = (P[smaller2[i]] - 1ll + mod) % mod ;
		z = (z * b) % mod ;
		ans = (ans + z) % mod ;
		// Take Both smaller and greater y from prev numbers and larger numbers from next numbers
		x = (P[smaller1[i]] - 1ll + mod) % mod ;
		y = (P[larger1[i]] - 1ll + mod) % mod ;
		z = (x * y) % mod ;
		b = (P[larger2[i]] - 1ll + mod) % mod ;
		z = (z * b) % mod ;
		ans = (ans + z) % mod ;
		//Handle double counting
		//ans = (ans - 1ll + mod) % mod ;
		// Take Both smaller and greater from next numbers and smaller from prev numbers
		x = (P[smaller2[i]] - 1ll + mod) % mod ;
		y = (P[larger2[i]] - 1ll + mod) % mod ;
		z = (x * y) % mod ;
		b = (P[smaller1[i]] - 1ll + mod) % mod ;
		z = (z * b) % mod ;
		ans = (ans + z) % mod ;
		// Take Both smaller and greater from next numbers and larger from prev numbers
		x = (P[smaller2[i]] - 1ll + mod) % mod ;
		y = (P[larger2[i]] - 1ll + mod) % mod ;
		z = (x * y) % mod ;
		b = (P[larger1[i]] - 1ll + mod) % mod ;
		z = (z * b) % mod ;
		ans = (ans + z) % mod ;
		// Handle double counting
		//ans = (ans - 1ll + mod) % mod ;
		// Take Both smaller and greater from next numbers and from prev numbers
		x = (P[smaller1[i]] - 1ll + mod) % mod ;
		y = (P[larger1[i]] - 1ll + mod) % mod ;
		z = (x * y) % mod ;
		a = (P[smaller2[i]] - 1ll + mod) % mod ;
		b = (P[larger2[i]] - 1ll + mod) % mod ;
		c = (a * b) % mod ;
		z = (z * c) % mod ;
		ans = (ans + z) % mod ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 28784