#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod=998244353;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;
  int n;

  BinaryIndexedTree(int sz) {
    n=sz;
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }

  T sum_between(int i, int j){
      if(i>j)return 0;
      return sum(j)-sum(i-1);
  }

  // a[0]+...+a[ret+1] >= x
    int lower_bound(T x){
        int ret = -1;
        int k = 1;
        while(2*k <= n) k <<= 1;
        for( ;k>0; k>>=1){
            if(ret+k < n && data[ret+k] < x){
                x -= data[ret+k];
                ret += k;
            }
        }
        return ret + 1;
    }
};



modint f(int a,int b,int c,int d){
    modint res=0;
    vector<int> nums={a,b,c,d};
    modint ox[4],o[4];
    rep(i,4){
        ox[i]=modint(2).pow(nums[i]);
        o[i]=ox[i]-1;
    }
    res+=o[0]*ox[1]*ox[2]*o[3];
    res+=ox[0]*o[1]*o[2]*ox[3];
    res-=o[0]*o[1]*o[2]*o[3];
    res+=ox[0]*ox[1]*ox[2]*ox[3];
    return res;
}

int main(){
    int n;cin>>n;
    int a[n],b[n],c[n],d[n];
    BinaryIndexedTree<int> BIT(n);
    vector<pair<int,int>> xy(n);
    rep(i,n)cin>>xy[i].first>>xy[i].second;
    vector<int> sy(n);rep(i,n)sy[i]=xy[i].second;
    sort(all(sy));
    sort(all(xy));
    rep(i,n){
        int y=xy[i].second;
        int zipy=lower_bound(all(sy),y)-sy.begin();
        BIT.add(zipy,1);
        a[i]=BIT.sum(zipy-1);
        b[i]=i-a[i];
    }
    reverse(all(xy));
    BinaryIndexedTree<int> inv(n);
    rep(i,n){
        int y=xy[i].second;
        int zipy=lower_bound(all(sy),y)-sy.begin();
        inv.add(zipy,1);
        c[n-1-i]=inv.sum(zipy-1);
        d[n-1-i]=i-c[n-1-i];
    }
    modint ans=0;
    rep(i,n){
        ans+=f(a[i],b[i],c[i],d[i]);
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 7296