#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

template <typename T>
struct BIT
{
    int n;
    vector<T> d;
    BIT(int n = 0) : n(n), d(n + 1) {}
    void add(int i, T x = 1)
    {
        for (i++; i <= n; i += i & -i)
        {
            d[i] += x;
        }
    }
    T sum(int i)
    {
        T x = 0;
        for (i++; i; i -= i & -i)
        {
            x += d[i];
        }
        return x;
    }
};

const int MOD = 998244353;

mint f(int a, int b, int c, int d)
{
    mint res = 0;
    vector<int> num = {a, b, c, d};
    vector<mint> o(4), ox(4);
    rep(i, 0, 4)
    {
        ox[i] = mint(2).pow(num[i]);
        o[i] = ox[i] - 1;
    }
    res += ox[0]*o[1]*o[2]*ox[3];
  res += o[0]*ox[1]*ox[2]*o[3];
  res -= o[0]*o[1]*o[2]*o[3];

  res += ox[0]*ox[1]*ox[2]*ox[3];
    return res;
}

void _main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> vs(N);
    rep(i, 0, N) cin >> vs[i].first >> vs[i].second;
    {
        map<int, int> m;
        rep(i, 0, N) m[vs[i].first] = 0;
        int j = 0;
        for (auto& p : m) p.second = j++;
        rep(i, 0, N) vs[i].first = m[vs[i].first];
    }
    {
        map<int, int> m;
        rep(i, 0, N) m[vs[i].second] = 0;
        int j = 0;
        for (auto& p : m) p.second = j++;
        rep(i, 0, N) vs[i].second = m[vs[i].second];
    }
    sort(all(vs));
    vector<int> a(N), b(N), c(N), d(N);
    rep(_, 0, 2)
    {
        { // a, b
            BIT<int> bit(N);
            rep(i, 0, N)
            {
                a[i] = bit.sum(vs[i].second);
                b[i] = i - a[i];
                bit.add(vs[i].second);
            }
        }

        reverse(all(vs));
        swap(a, c);
        swap(b, d);
        reverse(all(a));
        reverse(all(b));
        reverse(all(c));
        reverse(all(d));
    }
    mint ans = 0;
    rep(i, 0, N)
    {
        ans += f(a[i], b[i], c[i], d[i]);
    }
    cout << ans.x << endl;
}


Measured memory_bytes: 11264