#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long LL;

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
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;
  }
  void clear() {
    d = vector<T>(n+1);
  }
};

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  typedef long long ll;   
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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;
  }
};


typedef pair<int, int> P;

mint countCombinations(int a, int b, int c, int d)
{
  mint ret;
  mint qa = mint(2).pow(a);
  mint oa = qa-1;
  mint qb = mint(2).pow(b);
  mint ob = qb-1;
  mint qc = mint(2).pow(c);
  mint oc = qc-1;
  mint qd = mint(2).pow(d);
  mint od = qd-1;

  ret += oa * qb * qc * od;  //! a & d
  ret += qa * ob * oc * qd;  //! b & c 
  ret -= oa * ob * oc * od;  //! a & b & c & d
  ret += qa * qb * qc * qd;  //! including self

  return ret;
}

int main()
{
    int N;
    cin >> N;

    vector<P> p(N);
    for (int i = 0; i < N; ++i) {
      cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end());
    map<int, int> mapYtoIndex;
    for (int i = 0; i < N; ++i) {
      p[i].first = i; //! compress x
      mapYtoIndex[p[i].second] = i;
    }
    int y = 0;
    for (auto it : mapYtoIndex) {
      p[it.second].second = y; //! compress y
      ++y;
    }

    vector<int> a(N);    //! top left compared to the current point
    vector<int> b(N);    //! bottom left compared to the current point
    vector<int> c(N);    //! top right compared to the current point
    vector<int> d(N);    //! bottom right compared to the current point
    BIT<int> bit(N+1);
    for (int x = 0; x < N; ++x) {
      y = p[x].second;
      a[x] = bit.sum(y);
      b[x] = x - a[x];
      bit.add(y);
    }
    bit.clear();
    for (int x = N-1; 0 <= x; --x) {
      y = p[x].second;
      c[x] = bit.sum(y);
      d[x] = N - 1 - x - c[x];
      bit.add(y);
    } 

    mint ans;

    for (int i = 0; i < N; ++i) {
      ans += countCombinations(a[i], b[i], c[i], d[i]);
    }

    cout << ans.x << endl;

    return 0;
}



Measured memory_bytes: 15872