#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 998244353;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

template<class T> class BIT {

   public:
      vector<T> bit;
      int SIZE;

      void init(int N, T a) {
         SIZE = N + 1;
         bit.resize(SIZE);
         for (int i = 0; i < SIZE; i++) {
            bit[i] = a;
         }
      }
      // 1-indexed 
      void add(int a, T w) {
         for (int x = a; x <= SIZE; x += x & -x) bit[x] += w;
      }
      
      // [1, a], 1-indexed
      T sum(int a) {
         T ret = 0;
         for (int x = a; x > 0; x -= x & -x) ret += bit[x];
         return ret;
      }

      // [a, b), 1-indexed
      T sum(int a, int b) {
         return sum(b) - sum(a - 1);
      }

      // get k-th number with binary search, k: 0-indexed
      int getk(T k) {
         k++;
         T ret = 0;
         int N = 1;
         while (N < SIZE) N *= 2;
         for (int i = N / 2; i > 0; i /= 2) {
            if (ret + i < SIZE && bit[ret + i] < k) {
               k = k - bit[ret + i];
               ret = ret + i;
            }
         }
         return ret + 1;
      }
};

int main() {
   int N;
   cin >> N;
   
   int x[N], y[N];
   vector<int> xs, ys;

   for (int i = 0; i < N; i++) {
      cin >> x[i] >> y[i];
      xs.push_back(x[i]);
      ys.push_back(y[i]);
   }
   sort(xs.begin(), xs.end());
   xs.erase(unique(xs.begin(), xs.end()), xs.end());
   sort(ys.begin(), ys.end());
   ys.erase(unique(ys.begin(), ys.end()), ys.end());

   for (int i = 0; i < N; i++) {
      x[i] = lower_bound(xs.begin(), xs.end(), x[i]) - xs.begin();
      x[i]++;
      y[i] = lower_bound(ys.begin(), ys.end(), y[i]) - ys.begin();
      y[i]++;
   }
   
   BIT<int> bitL, bitR;
   bitL.init(N + 1, 0);
   bitR.init(N + 1, 0);
   for (int i = 0; i < N; i++) {
      bitR.add(y[i], 1);
   }
   int log[N];
   for (int i = 0; i < N; i++) {
      log[x[i] - 1] = i;
   }
   sort(x, x + N);

   ll ans = 0;
   for (int i = 0; i < N; i++) {
      int y2 = y[log[x[i] - 1]];
      bitR.add(y2, -1);
      int LU = bitL.sum(y2 + 1, N);
      int RU = bitR.sum(y2 + 1, N);
      int LD = bitL.sum(1, y2 - 1);
      int RD = bitR.sum(1, y2 - 1);
      // cout << i << " " << LU << " " << RU << " " << LD << " " << RD << endl;
      // cout << LU + RU + LD + RD + 1 << endl;
      ll tmp;
      tmp = 1;
      mul(tmp, llmodpow(2, LU));
      mul(tmp, llmodpow(2, RU));
      mul(tmp, llmodpow(2, LD));
      mul(tmp, llmodpow(2, RD));
      add(ans, tmp);
      tmp = llmodpow(2, LU) - 1;
      mul(tmp, llmodpow(2, RD) - 1);
      mul(tmp, llmodpow(2, RU));
      mul(tmp, llmodpow(2, LD));
      add(ans, tmp);
      tmp = llmodpow(2, RU) - 1;
      mul(tmp, llmodpow(2, LD) - 1);
      mul(tmp, llmodpow(2, LU));
      mul(tmp, llmodpow(2, RD));
      add(ans, tmp);
      tmp = llmodpow(2, LU) - 1;
      mul(tmp, llmodpow(2, RU) - 1);
      mul(tmp, llmodpow(2, LD) - 1);
      mul(tmp, llmodpow(2, RD) - 1);
      sub(ans, tmp);
      bitL.add(y2, 1);
   }
   ans %= MOD;
   if (ans < 0) ans += MOD; 
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 5996