#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using P = pair<int, int>;

template<int Mod> class ModInt {
  int v;
public:
  constexpr ModInt(const long long x = 0) noexcept : v((x % Mod + Mod) % Mod) {};
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    v += rhs.v;
    if (v >= Mod)
      v -= Mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (v < rhs.v)
      v += Mod;
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    v = int(1LL * v * rhs.v % Mod);
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1)
        *this *= rhs;
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  constexpr ModInt operator-() const noexcept { return ModInt(-v); }
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr bool operator==(const ModInt rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const ModInt rhs) const noexcept {
    return v != rhs.v;
  }
  constexpr ModInt pow(long long exp) const noexcept {
    ModInt res(1), mul(v);
    while (exp) {
      if (exp & 1)
        res *= mul;
      mul *= mul;
      exp >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt obj) noexcept {
    return os << obj.v;
  }
  friend istream &operator>>(istream &is, ModInt &obj) noexcept {
    long long tmp;
    is >> tmp;
    obj = ModInt<Mod>(tmp);
    return is;
  }
};
constexpr int MOD = 998244353;
using mint = ModInt<MOD>;

class BIT {
  vector<int> dat;
public:
  BIT (int n) {
    dat.resize(n+1, 0);
  }
  void add(int i, int n) {
    while (i < dat.size()) {
      dat[i] += n;
      i += i & -i;
    }
  }
  int sum(int i) {
    int res = 0;
    while (i > 0) {
      res += dat[i];
      i -= i & -i;
    }
    return res;
  }
  void clear() {
    for (int i = 1; i < dat.size(); i++)
      dat[i] = 0;
  }
};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<P> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());
  rep(loop, 2) {
    map<int, int> mp;
    if (!loop) {
      rep(i, n) mp[p[i].first] = 0;
      int i = 0;
      for (auto &e : mp)
        e.second = i++;
      rep(i, n) p[i].first = mp[p[i].first];
    } else {
      rep(i, n) mp[p[i].second] = 0;
      int i = 0;
      for (auto &e : mp)
        e.second = i++;
      rep(i, n) p[i].second = mp[p[i].second];
    }
  }
  BIT bit(n);
  vector<vector<int>> num(n, vector<int>(4));
  rep(i, n) {
    num[i][1] = bit.sum(n)-bit.sum(p[i].second);
    num[i][2] = bit.sum(p[i].second+1);
    bit.add(p[i].second+1, 1);
  }
  bit.clear();
  for (int i = n-1; i >= 0; i--) {
    num[i][3] = bit.sum(p[i].second+1);
    num[i][0] = bit.sum(n)-bit.sum(p[i].second);
    bit.add(p[i].second+1, 1);
  }
  mint ans = 0;
  rep(i, n) {
    rep(j, 1<<4) {
      mint res = 1;
      rep(k, 4) {
        if (j>>k & 1)
          res *= mint(2).pow(num[i][k])-1;
      }
      if (__builtin_popcount(j) >= 3 || j>>3&1 && j>>1&1 || j>>2&1 && j&1)
        ans += res*2;
      else
        ans += res;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15232