#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

//const int MOD = 1e9+7;
const int MOD = 998244353;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};

LL powmod(LL a, LL b){
    if(b == 0) return 1;
    if(b == 1) return a%MOD;

    if(b%2 == 0){
       LL tmp = powmod(a,b/2);
       return tmp * tmp % MOD;
    }else{
        return powmod(a,b-1) * a % MOD;
    }
}

LL f(LL a,LL b,LL c,LL d){
    LL res = 0;
    VL num = {a,b,c,d};
    VL o(4), ox(4);
    REP(i,4){
        ox[i] = powmod(2,num[i]);
        o[i] = ox[i] - 1;
    }
    res += (ox[0]*o[1] %MOD)*(o[2]*ox[3]%MOD);
    res %= MOD;
    res += (o[0]*ox[1]%MOD)*(ox[2]*o[3]%MOD);
    res %= MOD;
    res -= (o[0]*o[1]%MOD)*(o[2]*o[3]%MOD);
    res %= MOD;
    res += (ox[0]*ox[1]%MOD)*(ox[2]*ox[3]%MOD);
    res %= MOD;

    return res;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<PII> p(N);
    REP(i,N) cin >> p[i].first >> p[i].second;

    // compress x
    {

        map<int,int> mp;
        REP(i,N){
            mp[p[i].first] = 0;
        }
        int j = 0;
        for(auto&& p : mp){
            p.second = j++;
        }
        REP(i,N){
            p[i].first = mp[p[i].first];
        }
    }

    // compress y
    {

        map<int,int> mp;
        REP(i,N){
            mp[p[i].second] = 0;
        }
        int j = 0;
        for(auto&& p : mp){
            p.second = j++;
        }
        REP(i,N){
            p[i].second = mp[p[i].second];
        }
    }
    sort(p.begin(),p.end());
    VI a(N),b(N),c(N),d(N);
    REP(_,2){
        SegmentTree<int> seg(N,[](int a, int b){
            return a+b;
        },0);
        REP(i,N){
            a[i] = seg.query(0,p[i].second+1);
            b[i] = i - a[i];
            seg.update(p[i].second,seg[p[i].second]+1);
        }
        reverse(p.begin(),p.end());
        swap(a,c);
        swap(b,d);
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        reverse(c.begin(),c.end());
        reverse(d.begin(),d.end());

    }
    LL ans = 0;
    REP(i,N){
        dump(a[i])
        dump(b[i])
        dump(c[i])
        dump(d[i])
        ans += f(a[i],b[i],c[i],d[i]);
        ans %= MOD;
        dump(ans)
    }
    cout << ans << endl;



}


Measured memory_bytes: 11264