#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}


template<typename T>
vector<T> compress(vector<T> v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}

template<typename T>
map<T, Int> dict(const vector<T> &v){
  map<T, Int> res;
  for(Int i=0;i<(Int)v.size();i++)
    res[v[i]]=i;
  return res;
}


template<typename T>
struct BIT{
  Int n;
  vector<T> bit;
  //1-indexed
  BIT():n(-1){}
  BIT(Int n_,T d):n(n_),bit(n_+1,d){}

  T sum(Int i){
    T s=bit[0];
    for(Int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  void add(Int i,T a){
    if(i==0) return;
    for(Int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }

  Int lower_bound(Int w){
    if(w<=0) return 0;
    Int x=0,r=1;
    while(r<n) r<<=1;
    for(Int k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
        w-=bit[x+k];
        x+=k;
      }
    }
    return x+1;
  }

  T sum0(Int i){
    return sum(i+1);
  }
  void add0(Int i,T a){
    add(i+1,a);
  }

  T query(Int l,Int r){
    return sum(r-1)-sum(l-1);
  }

  T query0(Int l,Int r){
    return sum(r)-sum(l);
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> xs(n),ys(n);
  for(Int i=0;i<n;i++) cin>>xs[i]>>ys[i];

  {
    auto vx=compress(xs);
    auto vy=compress(ys);
    auto dx=dict(vx);
    auto dy=dict(vy);
    for(Int i=0;i<n;i++){
      xs[i]=dx[xs[i]];
      ys[i]=dy[ys[i]];
    }
  }

  {
    using P = pair<Int, Int>;
    vector<P> vp;
    for(Int i=0;i<n;i++) vp.emplace_back(xs[i],ys[i]);
    sort(vp.begin(),vp.end());
    for(Int i=0;i<n;i++) tie(xs[i],ys[i])=vp[i];
  }

  using M = Mint<Int, 998244353>;
  BIT<Int> bl(n+100,0);
  BIT<Int> br(n+100,0);
  for(Int i=0;i<n;i++) br.add0(ys[i],1);

  M ans{0};
  for(Int i=0;i<n;){
    Int tx=xs[i];
    Int l=i;
    while(i<n&&xs[i]==tx) i++;
    Int r=i;

    //cout<<l<<" "<<r<<endl;
    for(Int j=l;j<r;j++){
      br.add0(ys[j],-1);
    }

    ans+=M(2).pow(n)-M(1);

    Int num=r-l;
    for(Int j=l;j<r;j++){
      Int D=(j-l);
      Int U=num-(D+1);
      Int L=bl.query0(ys[j],ys[j]+1);
      Int R=br.query0(ys[j],ys[j]+1);

      Int W=br.query0(ys[j]+1,n+10);
      Int X=bl.query0(ys[j]+1,n+10);
      Int Y=bl.query0(0,ys[j]);
      Int Z=br.query0(0,ys[j]);

      ans-=(M(2).pow(L)-M(1))*M(2).pow(X+Y);
      ans-=(M(2).pow(R)-M(1))*M(2).pow(W+Z);
      ans-=(M(2).pow(U)-M(1))*M(2).pow(X+W);
      ans-=(M(2).pow(D)-M(1))*M(2).pow(Y+Z);

      ans-=M(2).pow(W)-M(1);
      ans-=M(2).pow(X)-M(1);
      ans-=M(2).pow(Y)-M(1);
      ans-=M(2).pow(Z)-M(1);

      ans-=(M(2).pow(W)-M(1))*(M(2).pow(X)-M(1));
      ans-=(M(2).pow(X)-M(1))*(M(2).pow(Y)-M(1));
      ans-=(M(2).pow(Y)-M(1))*(M(2).pow(Z)-M(1));
      ans-=(M(2).pow(Z)-M(1))*(M(2).pow(W)-M(1));
    }

    for(Int j=l;j<r;j++){
      bl.add0(ys[j],1);
    }
  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 31488