#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(int i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;



class runtime_modint {
  using u64 = std::uint_fast64_t;

  static u64 &mod() {
    static u64 mod_ = 0;
    return mod_;
  }

public:
  u64 a;

  runtime_modint(const u64 x = 0) : a(x % get_mod()) {}
  u64 &value() noexcept { return a; }
  const u64 &value() const noexcept { return a; }
  runtime_modint operator+(const runtime_modint rhs) const {
    return runtime_modint(*this) += rhs;
  }
  runtime_modint operator-(const runtime_modint rhs) const {
    return runtime_modint(*this) -= rhs;
  }
  runtime_modint operator*(const runtime_modint rhs) const {
    return runtime_modint(*this) *= rhs;
  }
  runtime_modint operator/(const runtime_modint rhs) const {
    return runtime_modint(*this) /= rhs;
  }
  runtime_modint &operator+=(const runtime_modint rhs) {
    a += rhs.a;
    if (a >= get_mod()) {
      a -= get_mod();
    }
    return *this;
  }
  runtime_modint &operator-=(const runtime_modint rhs) {
    if (a < rhs.a) {
      a += get_mod();
    }
    a -= rhs.a;
    return *this;
  }
  runtime_modint &operator*=(const runtime_modint rhs) {
    a = a * rhs.a % get_mod();
    return *this;
  }
  runtime_modint &operator/=(runtime_modint rhs) {
    u64 exp = get_mod() - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  runtime_modint pow(ll exp) {
    runtime_modint res(1),th;
    th=*this;

    while (exp) {
      if (exp % 2) {
        res *= th;
      }
      th *= th;
      exp /= 2;
    }
    return res;
  }


  static void set_mod(const u64 x) { mod() = x; }
  static u64 get_mod() { return mod(); }
};


template <class Monoid>
class SegmentTree
{
public:
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid M1;
  int sz;
  vector<Monoid> seg;

  SegmentTree(int n,const Func fu, const Monoid &m1): F(fu) , M1(m1) {init(n);}
  void init(int n)
  {
      sz= 1;
      while (sz < n) sz *= 2;
      seg.assign(sz * 2, M1);
  }
  void update(int k,const Monoid &x)
  {
    k+=sz;
    seg[k]=x;
    while(k>>=1)
    {
      seg[k]=F(seg[k*2],seg[k*2+1]);
    }
  }
  Monoid query(int l,int r)
  {
    Monoid L=M1,R=M1;
    l+=sz;r+=sz;
    for(;l<r;l>>=1,r>>=1)
    {
      if(l&1)L=F(L,seg[l++]);
      if(r&1)R=F(seg[--r],R);
    }
    return F(L,R);
  }
};

using mint=runtime_modint;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  mint::set_mod(998244353);
  ll n;cin>>n;
  struct p{
    ll x,y;
  };
  vector<p>poi(n);
  vector<ll>ty(n);
  rep(i,n){
    cin>>poi[i].x>>poi[i].y;
    ty[i]=poi[i].y;
  }
  sort(all(ty));
  map<ll,ll>iy;
  rep(i,n){
    iy[ty[i]]=i;
  }
  sort(all(poi),[&](p a,p b){return a.x<b.x;});
  SegmentTree<ll>st(n,[](ll a,ll b){return a+b;},0);
  auto rst=st;
  vector<vector<ll>>num(n+7,vector<ll>(4));
  rep(i,n){
    ll tiy=iy[poi[i].y];
    num[i][0]=st.query(0,tiy);
    num[i][1]=i-num[i][0];
    st.update(tiy,1);
  }
  rrep(i,n){
    ll tiy=iy[poi[i].y];
    num[i][2]=rst.query(0,tiy);
    num[i][3]=n-1-i-num[i][2];
    rst.update(tiy,1);
  }
  mint res,two(2);
  ll r=0;
  rep(i,n){
  // res+=two.pow(n)-(two.pow(num[i][0])+two.pow(num[i][3])-1)*(two.pow(num[i][1])+two.pow(num[i][2])-1);
    res+=two.pow(n-1);
    res+=(two.pow(num[i][1])-1)*(two.pow(num[i][2])-1)*two.pow(num[i][0]+num[i][3]);
    res+=(two.pow(num[i][0])-1)*(two.pow(num[i][3])-1)*two.pow(num[i][1]+num[i][2]);
    res-=(two.pow(num[i][0])-1)*(two.pow(num[i][1])-1)*(two.pow(num[i][2])-1)*(two.pow(num[i][3])-1);

  }

  cout<<res.value()<<endl;

  return 0;

}


Measured memory_bytes: 41728