#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define endl "\n"
typedef long long lint;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define all(x) (x).begin(),(x).end()
#define INF (1LL<<60)
#define MOD 1000000007
#define input 
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};

struct BIT{
    vector<lint> bit;
    lint n;
    BIT(lint n):n(n){
        bit.resize(n+1,0);
    }
    //1-indexed [1,x]-sum
    lint sum(lint x){
        lint res=0;
        for(lint i=x;i>0;i-=i&-i)res+=bit[i];
        return res;
    }
    //1-indexed [x,y]-sum
    lint sum(lint x,lint y){
        return sum(y)-sum(x-1);
    }
    //1-indexed
    void add(lint x,lint val){
        if(x>n)return;
        for(lint i=x;i<=n;i+=i&-i)bit[i]+=val;
    }
};
template <uint_fast64_t Modulus> class mint {
    using u64 = uint_fast64_t;
    public:
    u64 a;
    constexpr mint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr mint operator+(const mint rhs) const noexcept {
        return mint(*this) += rhs;
    }
    constexpr mint operator-(const mint rhs) const noexcept {
        return mint(*this) -= rhs;
    }
    constexpr mint operator*(const mint rhs) const noexcept {
        return mint(*this) *= rhs;
    }
    constexpr mint operator/(const mint rhs) const noexcept {
        return mint(*this) /= rhs;
    }
    constexpr mint &operator+=(const mint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr mint &operator-=(const mint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr mint &operator*=(const mint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr mint &operator/=(mint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    constexpr mint operator++(int n) const noexcept {
        return mint(*this) +=1;
    }
    constexpr mint operator--(int n) const noexcept {
        return mint(*this) -=1;
    }
};
template <uint_fast64_t Modulus>ostream& operator<<(ostream& lhs, const mint<Modulus>& rhs) noexcept {
    lhs << rhs.a;
    return lhs;
}
template <uint_fast64_t Modulus>istream& operator>>(istream& lhs, const mint<Modulus>& rhs) noexcept {
    lhs >> rhs.a;
    return lhs;
}
template <uint_fast64_t Modulus>
inline mint<Modulus> pow(mint<Modulus> m,lint n){
    if(n==0)return 1;
    else if(n%2==0){
        mint<Modulus> x=pow(m,n/2);
        return x*x;
    }else{
        return m*pow(m,n-1);
    }
}
template <uint_fast64_t Modulus>
inline mint<Modulus> fact(lint a){
    return a?fact<Modulus>(a-1)*a:1;
}
int main(){
    lint n;
    cin>>n;
    vector<pair<lint,lint>>p(n);
    rep(i,n)cin>>p[i].first>>p[i].second;
    sort(all(p));
    vector<lint> a(n),b;
    rep(i,n)a[i]=p[i].second;
    b=a;
    sort(all(b));
    b.erase(unique(all(b)),b.end());
    rep(i,n)a[i]=lower_bound(all(b),a[i])-b.begin()+1;
    BIT bit=BIT(n);
    vector<lint> v1(n),v2(n),v3(n),v4(n);
    rep(i,n){
        v1[i]=bit.sum(a[i]);
        v3[i]=i-v1[i];
        bit.add(a[i],1);
    }
    bit=BIT(n);
    reverse(all(a));
    rep(i,n){
        v2[i]=bit.sum(a[i]);
        v4[i]=i-v2[i];
        bit.add(a[i],1);
    }
    reverse(all(v2));
    reverse(all(v4));
    mint<998244353> ans=0;
    mint<998244353> two=2;
    rep(i,n){
        ans+=pow(two,n)-1;
        ans-=pow(two,v1[i]+v2[i])+pow(two,v1[i]+v3[i])+pow(two,v2[i]+v4[i])+pow(two,v3[i]+v4[i])-4;
        ans+=pow(two,v1[i])+pow(two,v2[i])+pow(two,v3[i])+pow(two,v4[i])-4;
    }
    cout<<ans;
}

Measured memory_bytes: 15892