#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-10;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll bit[1200010];
ll u;
void bitinit(ll n){
    ll y=1;
    rep(i,0,69){
        
        if(y>=n){
            u=y;
            break;
        }
        y*=2;
    }
    fill(bit,bit+u+10,0);
}
void add(ll n,ll x){
    ll i=n;
    bit[i]+=x;
    bit[i]%=mod;
    while(i<u){
        i+=i&(-i);
        bit[i]+=x;
        bit[i]%=mod;
    }
}
ll sum(ll n){
    ll i=n;
    ll ret=0;
    while(i>0){
        ret+=bit[i];
        i-=i&(-i);
        ret%=mod;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    vector<int> v;
    int x[n],y[n];
    rep(i,0,n){
        cin>>x[i]>>y[i];
        v.push_back(x[i]);
        v.push_back(y[i]);
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    unordered_map<int,int> mp;
    rep(i,0,v.size())mp[v[i]]=i+1;
    vector<ppii> w,ww;
    
    rep(i,0,n){
        x[i]=mp[x[i]];
        y[i]=mp[y[i]];
        w.push_back({{x[i],y[i]},i});
        ww.push_back({{y[i],x[i]},i});
    }
    sort(w.begin(),w.end());
    bitinit(2*n+10);
    ll cnt[n][8];
    rep(i,0,w.size()){
        int nx=w[i].first.first,ny=w[i].first.second,num=w[i].second;
        cnt[num][1]=sum(ny);
        cnt[num][6]=sum(u);
        cnt[num][0]=cnt[num][6]-cnt[num][1];
        add(ny,1);
    }
    sort(w.begin(),w.end(),greater<ppii>());
    bitinit(2*n+10);
    rep(i,0,w.size()){
        int nx=w[i].first.first,ny=w[i].first.second,num=w[i].second;
        cnt[num][2]=sum(ny);
        cnt[num][7]=sum(u);
        cnt[num][3]=cnt[num][7]-cnt[num][2];
        add(ny,1);
    }
    sort(ww.begin(),ww.end());
    rep(i,0,ww.size()){
        int num=ww[i].second;
        cnt[num][5]=i;
        cnt[num][4]=n-1-i;
    }
    /*rep(i,0,n){
        rep(j,0,8)cout<<cnt[i][j]<<" ";
        cout<<endl;
    }*/
    ll ans=0;
    rep(i,0,n){
        ll sum=beki(2,n,mod2);
        ll sum2=beki(2,cnt[i][6],mod2)-1+beki(2,cnt[i][7],mod2)-1
        +beki(2,cnt[i][4],mod2)-1+beki(2,cnt[i][5],mod2)-1+mod2;
        sum2%=mod2;
        rep(j,0,4){
            sum2+=-beki(2,cnt[i][j],mod2)+1+mod2;
            sum2%=mod2;
        }
        sum=sum-sum2+mod2;
        sum=(sum-1+mod2)%mod2;
        ans+=sum%mod2;
        ans%=mod2;
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 46108