#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}


int seg[800005];

void build(int ver,int tl,int tr)
{
    if(tl>tr)
        return ;
    else if(tl==tr)
    {
        seg[ver]=0;
    }
    else
    {
        int tm=(tl+tr)/2;
        build(2*ver,tl,tm);
        build(2*ver+1,tm+1,tr);
        seg[ver]=seg[2*ver]+seg[2*ver+1];
    }
}


void upd(int ver,int tl,int tr,int pos,int val)
{
    if(tl>tr)
        return ;
    else if(tl==tr)
        seg[ver]+=val;
    else
    {
        int tm=(tl+tr)/2;
        if(tm>=pos)
            upd(2*ver,tl,tm,pos,val);
        else
            upd(2*ver+1,tm+1,tr,pos,val);
        seg[ver]=seg[2*ver]+seg[2*ver+1];
    }
}


int get(int ver,int tl,int tr,int l,int r)
{
    if(tl>tr||l>r||tr<l||r<tl)  
        return 0;
    else if(tl==l&&tr==r)
        return seg[ver];
    else
    {
        int tm=(tl+tr)/2;
        return get(2*ver,tl,tm,l,min(tm,r))+get(2*ver+1,tm+1,tr,max(tm+1,l),r);
    }
}

bool comp1(pair<int,int>a,pair<int,int>b)
{
    if(a.first==b.first)
        return a<b;
    return a.first<b.first;
}

const int mod=998244353;
int pp[200005];
vector<pair<int,int> >lol1,lol2;
int find(int ind)
{
    int ans=0;
    int x=(pp[lol1[ind].first]+mod-1)%mod;
    int y=(pp[lol2[ind].second]+mod-1)%mod;
    int z=(pp[lol1[ind].second])%mod;
    int w=(pp[lol2[ind].first])%mod;
    ans+=(x*y%mod*z%mod*w%mod)%mod;
    ans%=mod;
    z+=mod-1;w+=mod-1;x+=1;y+=1;
    x%=mod;
    y%=mod;z%=mod;w%=mod;
    ans+=(x*y%mod*z%mod*w%mod)%mod;
    ans%=mod;
    x+=mod-1;
    y+=mod-1;
    x%=mod;
    y%=mod;
    ans+=mod-(x*y%mod*z%mod*w%mod)%mod;
    // ans*=2;
    ans%=mod;
    return ans;
}

int find2(int ind)
{
    int ans=0;
    int x=(pp[lol1[ind].first]+mod)%mod;
    int y=(pp[lol2[ind].second]+mod)%mod;
    int z=(pp[lol1[ind].second]+mod)%mod;
    int w=(pp[lol2[ind].first]+mod)%mod;
    ans+=(x*y%mod*z%mod*w%mod)%mod;
    ans%=mod;
    return ans;
}

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    pp[0]=1;
    for(int i=1;i<=200000;i++)
        pp[i]=pp[i-1]*2%mod;
    int n;
    cin>>n;
    pair<int,int>p[n];
    set<int>s;    
    for(int i=0;i<n;i++)
    {
        cin>>p[i].first>>p[i].second;
        s.insert(p[i].first);
    }
    map<int,int>mm;
    int cnt=0;
    for(auto i:s)
        mm[i]=++cnt;
    s.clear();
    for(int i=0;i<n;i++)
    {
        p[i].first=mm[p[i].first];
        s.insert(p[i].second);
    }
    mm.clear();
    cnt=0;
    for(auto i:s)
        mm[i]=++cnt;
    for(int i=0;i<n;i++)
        p[i].second=mm[p[i].second];
    sort(p,p+n,comp1);
    for(int i=0;i<n;i++)
    {
        int x=get(1,1,cnt,1,p[i].second-1);
        int y=get(1,1,cnt,p[i].second+1,cnt);
        lol1.push_back({x,y});        
        upd(1,1,cnt,p[i].second,1);
    } 

    build(1,1,cnt);
    for(int i=n-1;i>=0;i--)
    {
        int x=get(1,1,cnt,1,p[i].second-1);
        int y=get(1,1,cnt,p[i].second+1,cnt);
        lol2.push_back({x,y});        
        upd(1,1,cnt,p[i].second,1);
    }
    reverse(lol2.begin(),lol2.end());
    int ans=0;
    for(int i=0;i<n;i++)
    {
        ans+=find(i);
        ans%=mod;
    }
    ans%=mod;
    for(int i=0;i<n;i++)
    {
        ans+=find2(i);
        ans%=mod;
    }
    cout<<ans;
}       


Measured memory_bytes: 43112