#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
const ll mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};


template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};



int main(){
    int n;
    cin >> n;
    vector<P> p(n);
    rep(i, n) cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());
    {
        map<int, int> mp;
        rep(i, n) mp[p[i].first] = 0;
        int id = 0;
        for (auto& m : mp) {
            m.second = id++;
        }
        rep(i, n) p[i].first = mp[p[i].first];
    }
    {
        map<int, int> mp;
        rep(i, n) mp[p[i].second] = 0;
        int id = 0;
        for (auto& m : mp) {
            m.second = id++;
        }
        rep(i, n) p[i].second = mp[p[i].second];
    }
    BIT<int> bit(n);
    BIT<int> bit2(n);
    mint ans(0);
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    vector<int> d(n);


    rep(i, n) {
        b[i] = bit.sum(p[i].second, n);
        c[i] = bit.sum(p[i].second-1);
        bit.add(p[i].second);
    }
    for (int i=n-1; i>=0; i--) {
        a[i] = bit2.sum(p[i].second, n);
        d[i] = bit2.sum(p[i].second-1);
        bit2.add(p[i].second);
    }
    /*
    rep(i, n) {
        debug(p[i].first);
        debug(p[i].second);
    }    
    rep(i, n) {
        debug(a[i]);
        debug(b[i]);
        debug(c[i]);
        debug(d[i]);
    }
    */
    
    
    rep(i, n) {
        mint res(0);
        mint t(2);
        /*
        res += (mint(2).pow(n) - mint(1));
        res -= (mint(2).pow(a[i]+b[i]) - mint(1));
        res -= (mint(2).pow(b[i]+c[i]) - mint(1));
        res -= (mint(2).pow(c[i]+d[i]) - mint(1));
        res -= (mint(2).pow(d[i]+a[i]) - mint(1));
        res += (mint(2).pow(a[i]) - mint(1));
        res += (mint(2).pow(b[i]) - mint(1));
        res += (mint(2).pow(c[i]) - mint(1));
        res += (mint(2).pow(d[i]) - mint(1));
        */
        res += t.pow(n-1);
        res += (t.pow(a[i])-1) * (t.pow(c[i])-1) * t.pow(b[i]+d[i]);
        res += (t.pow(b[i])-1) * (t.pow(d[i])-1) * t.pow(a[i]+c[i]);
        res -= (t.pow(a[i])-1) * (t.pow(c[i])-1) * (t.pow(b[i])-1) * (t.pow(d[i])-1);
        ans += res;
        //debug(ans.x);
    }
    
    
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 14128