#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
vector<P> x,x_,y,y_,points;
vector<ll> pow2={1};
int a[500000][4];


struct SegmentTree{
    private:
        int n;
        vector<ll> node; //セグ木の持つデータの型を入力
        ll e = 0; //単位元
    public:
        ll F(ll a,ll b){
            return a+b;//二項演算
        }

        void init(vector<ll> v) {
            int sz = v.size();
            n = 1; while(n < sz) n *= 2;
            node.resize(2*n-1, e);

            rep(i,sz) node[i+n-1] = v[i];
            per(i,n-1) node[i] = F(node[2*i+1], node[2*i+2]);

            //rep(i,2*n-1) cout << node[i] << endl;
        }

        void update(int x,ll val){
            x += n-1;
            node[x] = val;
            while(x > 0) {
                x =(x-1)/2;
                node[x]=F(node[2*x+1],node[2*x+2]);
            }
        
        }

        ll get(int a, int b, int k=0, int l=0, int r=-1) {
            if(r < 0) r = n;
            if(r <= a || b <= l) return e;
            if(a <= l && r <= b) return node[k];

            ll vl = get(a, b, 2*k+1, l, (l+r)/2);
            ll vr = get(a, b, 2*k+2, (l+r)/2, r);
            return F(vl, vr);
        }
};

void solve(){
    cin >> n;
    points.resize(n,P(0,0));
    rep(i,n){
        int x1,y1;
        cin >> x1 >> y1;
        x.push_back(P(x1,i));
        y.push_back(P(y1,i));
    }
    rep(i,n) pow2.push_back(pow2.back()*2%mod);
    
    x_=x;y_=y;
    sort(x_.begin(),x_.end());
    sort(y_.begin(),y_.end());
    rep(i,n) points[x_[i].second].first=i;
    rep(i,n) points[y_[i].second].second=i;
    //rep(i,n) cout << points[i].first << " " << points[i].second << endl;
    sort(points.begin(),points.end());
    vector<ll> vec(n,0);
    SegmentTree seg1;seg1.init(vec);
    SegmentTree seg2;seg2.init(vec);
    rep(i,n){
        a[i][0]=seg1.get(0,points[i].second);
        a[i][1]=i-seg1.get(0,points[i].second);
        seg1.update(points[i].second,1);
    }
    per(i,n){
        a[i][2]=seg2.get(0,points[i].second);
        a[i][3]=(n-i-1)-seg2.get(0,points[i].second);
        seg2.update(points[i].second,1);
    }
    ll ans=0;
    rep(i,n){
        //cout << a[i][0] << " " << a[i][1] << " " << a[i][2] << " " << a[i][3] << endl;
        ans+=pow2[n]-1;
        ans%=mod;
        ans+=mod-pow2[a[i][0]+a[i][1]];
        ans%=mod;
        ans+=mod-pow2[a[i][0]+a[i][2]];
        ans%=mod;
        ans+=mod-pow2[a[i][1]+a[i][3]];
        ans%=mod;
        ans+=mod-pow2[a[i][2]+a[i][3]];
        ans%=mod;
        ans+=pow2[a[i][0]]+pow2[a[i][1]]+pow2[a[i][2]]+pow2[a[i][3]];
        ans%=mod;
        //cout << ans << endl;
    }

    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 25040