#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 998244353;

ll f(ll a, ll b, ll c, ll d, vl& pow2) {
  ll res = 0;
  vl num = {a, b, c, d};
  vl o(4), ox(4);
  rep(i, 4) {
    ox[i] = pow2[num[i]];
    o[i] = ox[i] - 1;
  }
  // for (int x = 0; x < (1<<4); x++) {
  //   vl tmp(4);
  //   rep(k, 4) {
  //     if ((x>>(k-1))&1) {
  //       tmp[k] = ox[k];
  //     } else {
  //       tmp[k] = o[k];
  //     }
  //   }
  //   res = (res + tmp[0]*tmp[1]%MOD*tmp[2]%MOD*tmp[3]%MOD) % MOD;
  // }
  res = (res + ox[0] * o[1] % MOD * o[2] % MOD * ox[3] % MOD) % MOD;
  res = (res + o[0] * ox[1] % MOD * ox[2]% MOD * o[3] % MOD) % MOD;
  res = (res + MOD - o[0] * o[1] % MOD * o[2] % MOD * o[3] % MOD) % MOD;
  res = (res + ox[0] * ox[1] % MOD * ox[2] % MOD * ox[3] % MOD) % MOD;
  return res;
}

class SegTree {
 private:
  const ll def_val_ = 0;
  vl val_;
  ll n_;

  ll comp(ll l, ll r) { return l + r; }

  ll getr(ll x, ll y, ll k, ll l, ll r) {
    if (y <= l || r <= x) return def_val_;
    if (x <= l && r <= y) return val_[k];
    auto vl = getr(x, y, 2 * k + 1, l, (l + r) / 2);
    auto vr = getr(x, y, 2 * k + 2, (l + r) / 2, r);
    return comp(vl, vr);
  }

 public:
  SegTree(ll size) {
    n_ = 1;
    while (n_ < size) n_ *= 2;
    val_ = vl(2 * n_, def_val_);
  }

  void update(ll i, ll v) {
    i += (n_ - 1);
    val_[i] = v;
    while (i > 0) {
      i = (i - 1) / 2;
      val_[i] = comp(val_[2 * i + 1], val_[2 * i + 2]);
    }
  }

  // get XXX value between [x,y)
  ll getRange(ll x, ll y) { return getr(x, y, 0, 0, n_); }
};

ll cnt(ll x, vl& pow2) {
  if (x == 0)
    return 1;
  else
    return pow2[x] - 1;
}

int main() {
  //
  ll n;
  cin >> n;
  set<ll> xs, ys;
  set<ll, greater<ll>> xs_inv;
  map<ll, ll> x2y;

  vl pow2(n + 1);
  pow2[0] = 1;
  REP(i, 1, n + 1) { pow2[i] = pow2[i - 1] * 2 % MOD; }

  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    xs.insert(x);
    xs_inv.insert(x);
    x2y[x] = y;
    ys.insert(y);
  }
  SegTree stL(n), stR(n);
  vector<pll> fromL(n), fromR(n);
  map<ll, ll> y2idx;
  ll idx = 0;
  for (auto& y : ys) {
    y2idx[y] = idx++;
  }
  idx = 0;
  for (auto& x : xs) {
    ll y = y2idx[x2y[x]];
    ll u = stL.getRange(y + 1, n);
    ll l = stL.getRange(0, y);
    fromL[idx++] = {u, l};
    stL.update(y, 1);
  }
  idx = n - 1;
  for (auto& x : xs_inv) {
    ll y = y2idx[x2y[x]];
    ll u = stR.getRange(y + 1, n);
    ll l = stR.getRange(0, y);
    fromR[idx--] = {u, l};
    stR.update(y, 1);
  }
  ll ans = 0;
  rep(i, n) {
    ll a = fromL[i].first;
    ll b = fromL[i].second;
    ll c = fromR[i].first;
    ll d = fromR[i].second;
    // cout << a << ":" << b << ":" << c << ":" << d << endl;
    ans = (ans + f(a, b, c, d, pow2)) % MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 71424