#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

constexpr int MOD = 998244353;
template<int MOD>
struct Modint {
  long long val;
  constexpr Modint(long long v = 0) noexcept : val(v% MOD) {
    if (val < 0) val += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Modint operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Modint operator + (const Modint& r) const noexcept { return Modint(*this) += r; }
  constexpr Modint operator - (const Modint& r) const noexcept { return Modint(*this) -= r; }
  constexpr Modint operator * (const Modint& r) const noexcept { return Modint(*this) *= r; }
  constexpr Modint& operator += (const Modint& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Modint& operator -= (const Modint& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Modint& operator *= (const Modint& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr bool operator == (const Modint& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Modint& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream& os, const Modint<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr istream& operator >> (istream& is, Modint<MOD>& x) noexcept {
    return is >> x.val;
  }

  constexpr Modint<MOD> pow(long long n) const noexcept {
    if (!n) return 1;
    auto t = pow(n >> 1);
    t *= t;
    if (n & 1) t *= *this;
    return t;
  }
  friend constexpr Modint<MOD> modpow(const Modint<MOD>& a, long long n) noexcept {
    return a.pow(n);
  }

  friend constexpr Modint<MOD> Ncr(Modint<MOD> a, int n) {
    Modint<MOD> p = 1, q = 1;

    while (n > 0) {
      p *= a;
      a -= 1;
      q *= n--;
    }

    return p / q;
  }

  // for prime mod
  constexpr Modint inv() const { return pow(MOD - 2); }
  constexpr Modint& operator /= (const Modint& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Modint operator / (const Modint& r) const noexcept { return Modint(*this) /= r; }
};
using mint = Modint<MOD>;

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  // 全事象: 2^N - 1

  // 1次元で考える
  // それぞれの点に対し、それを含む区間がいくつあるか？
  // ある点の左にある点の数:L, 右の点の数:R とおくとき
  // (L+1) * (R+1)

  // 次に2次元で考える
  // どの点もXかYが一致することはない
  // 2点を含む長方形を考える場合、
  // (左上+1) * (右下+1) + (左下+1) * (右上+1) - 1

  // ある点を含む集合の数
  // その点を含む or 左上と右下の点を含む or 右上と左下の点を含む

  int N;
  cin >> N;

  struct Point {
    int x, y;
  };
  auto xcmp = [](const Point& l, const Point& r) {
    return l.x < r.x;
  };
  auto ycmp = [](const Point& l, const Point& r) {
    return l.y < r.y;
  };

  // 処理中の点より[左,右]の点のy座標
  vector<int> ls, rs(N);

  // xでソートした全ての点
  vector<Point> ps(N);

  F0R(i, N) {
    int x, y;
    cin >> ps[i].x >> ps[i].y;
    rs[i] = ps[i].y;
  }
  sort(rng(ps), xcmp);
  sort(rng(rs));

  vector<mint> two(N + 1);
  two[0] = 1;
  F0R(i, N) {
    two[i + 1] = two[i] * 2;
  }

  mint result = 0;

  F0R(i, N) {
    int ri = lower_bound(rng(rs), ps[i].y) - rs.begin();
    int li = lower_bound(rng(ls), ps[i].y) - ls.begin();
    rs.erase(rs.begin() + ri);

    // 処理する点より左上,右上,左下,右下の点の数
    int lu = li, ru = ri, ld = ls.size() - li, rd = rs.size() - ri;
    //cout << lu << ',' << ru << ',' << ld << ',' << rd << newl;

    // この点を含む
    result += two[N - 1];

    // この点を含まず、左上と右下を含む
    result += (two[lu] - 1) * (two[rd] - 1) * two[ru + ld];

    // この点を含まず、右上と左下を含み、左上と右下は含まない
    result += (two[ru] - 1) * (two[ld] - 1);

    // この点を含まず、右上と左下を含み、左上は含み右下は含まない
    result += (two[ru] - 1) * (two[ld] - 1) * (two[lu] - 1);

    // この点を含まず、右上と左下を含み、右下は含み左上は含まない
    result += (two[ru] - 1) * (two[ld] - 1) * (two[rd] - 1);

    ls.insert(ls.begin() + li, ps[i].y);
  }

  cout << result;
}
#endif


Measured memory_bytes: 8188