#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<unordered_map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<bitset>
#include<fstream>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
#include<fstream>
const ll INF=9223372036854775807;
const ll mod=998244353
;
int  MOD(int  a, int  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b, ll  c)
{
    return max(c,max(a,b));
}
ll min3(ll  a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y,ll mod1)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod1;
        y = y>>1;
        x = (x*x)%mod1;
    }
    return res;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x,ll p)
{
    return power(x,p-2,p);
}
vll bit;
void upd(int i,int v)
{
    for(;i<=bit.size()-1;i=i+((i)&(-i)))
    {
        bit[i]+=v;
    }
}
ll query(int ind)
{
    ll ans=0;
    for(;ind>0;ind=ind-((ind)&(-ind)))
    {
        ans+=bit[ind];
    }
    return ans;
}
int main()
{
    fastio;
    ll n;
    cin>>n;
    vector<pair<ll,ll>> v(n);
    vll ff;
    bit.resize(n+1);
    for(int i=0;i<n;i++)
    {
        cin>>v[i].f>>v[i].s;
        ff.push_back(v[i].s);
    }
    sort(all(ff));
    sort(all(v));
    vector<vll> vv(n);
    map<ll,ll> y_rank,x_rank;
    for(ll i=0;i<n;i++)
    {
        x_rank[v[i].f]=i;
        y_rank[ff[i]]=i;
    }
    for(ll i=0;i<n;i++)
    {
        vv[i].resize(4);
        vv[i][0]=query(y_rank[v[i].s]+1);
        vv[i][1]=i-vv[i][0];
        upd(y_rank[v[i].s]+1,1);
    }
    for(ll i=0;i<=n;i++)
    {
        bit[i]=0;
    }
    for(ll i=n-1;i>=0;i--)
    {
        vv[i][2]=query(y_rank[v[i].s]+1);
        vv[i][3]=(n-1-i)-vv[i][2];
        upd(y_rank[v[i].s]+1,1);
    }
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        ans-=((power(2,x_rank[v[i].f],mod)-1+mod)%mod);
        ans=(ans%mod);
        ans-=((power(2,n-x_rank[v[i].f]-1,mod)-1+mod)%mod);
        ans=(ans%mod);
        ans-=((power(2,y_rank[v[i].s],mod)-1+mod)%mod);
        ans=(ans%mod);
        ans-=((power(2,n-y_rank[v[i].s]-1,mod)-1+mod)%mod);
        ans=(ans%mod);
        for(ll j=0;j<4;j++)
        {
            ans+=((power(2,vv[i][j],mod)-1+mod)%mod);
            ans=(ans%mod);
        }
        ans+=(((power(2,n,mod)-1+mod))%mod);
        ans=(ans%mod);
    }
    cout<<ans;
}



Measured memory_bytes: 45552