#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define foreach(i,a) for(auto &i:a)
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}

template<class T> class BIT{
private:
  ll n;
  vector<T> node;
  function<T(T,T)> dot;
  T e;
public:
  BIT(vector<T>&& A,function<T(T,T)> dot,T e):dot(dot),e(e){
    n=A.size();
    node.resize(n+1);
    rep(i,n) node[i+1]=A[i];
    rep(i,1,n+1){
      ll j=i+(i&-i);
      if(j<=n) node[j]=dot(node[i],node[j]);
    }
  }
  void add(ll i,ll w=1){
    ++i;
    while(i<=n){
      node[i]=dot(node[i],w);
      i+=i&-i;
    }
  }
  T sum(ll i){
    T res=e;
    while(i){
      res=dot(res,node[i]);
      i-=i&-i;
    }
    return res;
  }
};

template<int MOD> struct ModInt {
  static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
  ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
  ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
  int get() const { return (int)x; }
  ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
  ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
  ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
  ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
  ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
    while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
    return ModInt(u); }
  bool operator==(ModInt that) const { return x == that.x; }
  bool operator!=(ModInt that) const { return x != that.x; }
  ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
  ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }

const ll MOD=998244353;
using mint=ModInt<MOD>;

void solve(){
  ll n; cin>>n;
  vector<pll> R(n);
  rep(i,n) cin>>R[i].second>>R[i].first; // 座圧のために逆にしておく

  // coordinate compress
  sort(R.begin(),R.end());
  rep(i,n) R[i].first=i;
  rep(i,n) swap(R[i].first,R[i].second);
  sort(R.begin(),R.end());
  rep(i,n) R[i].first=i;

  // line sweep
  auto Q=make_v(n,4,(ll)0);
  auto dot=[](ll a,ll b){return a+b;};
  ll e=0;
  // left
  BIT<ll> bit1(vector<ll>(n,0),dot,e);
  rep(i,n){
    ll y=R[i].second;
    bit1.add(y);
    ll L=bit1.sum(y);
    Q[i][1]=i-L;
    Q[i][2]=L;
  }
  // right
  BIT<ll> bit2(vector<ll>(n,0),dot,e);
  rep(i,n){
    ll y=R[n-1-i].second;
    bit2.add(y);
    ll L=bit2.sum(y);
    Q[n-1-i][0]=i-L;
    Q[n-1-i][3]=L;
  }
  mint ans=0;
  rep(i,n){
    mint a=(mint)2^Q[i][0];
    mint b=(mint)2^Q[i][1];
    mint c=(mint)2^Q[i][2];
    mint d=(mint)2^Q[i][3];
    ans+=(a-1)*b*(c-1)*d;
    ans+=a*(b-1)*c*(d-1);
    ans-=(a-1)*(b-1)*(c-1)*(d-1);
    ans+=a*b*c*d;
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 22120