// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

template <typename T>
class Bit {
private:
    V<T> data;
    T identity_ele;

public:
    Bit(ll size, T identity_ele) : identity_ele(identity_ele) {
        ll newsize = 1;
        while(newsize < size) {
            newsize = newsize << 1;
        }
        data = V<T>(newsize + 1, identity_ele);
    }

    /*
     * 0-origin
     * sum of [0, pos)
     */
    T sum(ll pos) {
        T ret = identity_ele;
        while(pos > 0) {
            ret += data[pos];
            pos -= pos & -pos;
        }
        return ret;
    }

    /*
     * 0-origin
     * sum of [l, r)
     */
    T sum(ll l, ll r) {
        return sum(r) - sum(l);
    }

    /*
     * 0-origin
     */
    void add(ll pos, T delta) {
        pos++;
        while(pos <= data.size()) {
            data[pos] = data[pos] + delta;
            pos += pos & -pos;
        }
    }
};

const ll mod = 998244353;

int main() {
    ll N;
    cin >> N;
    V<ll> x_lis(N), y_lis(N), pow2(N + 10);

    {
        pow2[0] = 1;
        for(ll i = 1; i < pow2.size(); i++) pow2[i] = 2 * pow2[i - 1] % mod;
    }

    V<PLL> coors(N);
    for(ll i = 0; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        coors[i] = PLL(x, y);
        x_lis[i] = x;
        y_lis[i] = y;
    }

    sort(ALL(x_lis));
    sort(ALL(y_lis));
    auto get_id = [](const V<ll> &v, ll num) {
        return distance(v.begin(),
                        lower_bound(ALL(v), num));
    };
    auto get_x_id = [&](ll num) { return get_id(x_lis, num); };
    auto get_y_id = [&](ll num) { return get_id(y_lis, num); };

    ll cnt = 0;
    {
        Bit<ll> bit(N + 10, 0);
        Bit<ll> bit_opposite(N + 10, 0);
        for(auto y : y_lis) bit_opposite.add(get_y_id(y), 1);
        sort(ALL(coors));
        for(auto &&ele : coors) {
            ll x, y;
            tie(x, y) = ele;
            ll y_id = get_y_id(y);
            bit_opposite.add(y_id, -1);
            ll left = bit.sum(N + 10);
            ll right = N - left - 1;
            cnt += pow2[left] - 1;
            cnt += pow2[right] - 1;
            DEBUG(PLL(left, right));
#if 1
            for(ll i = 0; i <= 1; i++) {
                auto &bit_i = (i ? bit : bit_opposite);
                ll sum = bit_i.sum(N + 10);
                ll half = bit_i.sum(y_id);
                DEBUG(PLL(sum, half));
                cnt += mod - (pow2[half] - 1);
                cnt += mod - (pow2[sum - half] - 1);
            }
#endif
            cnt %= mod;
            bit.add(y_id, 1);
        }
    }

    DEBUG(cnt);
    
    {
        Bit<ll> bit(N + 10, 0);
        sort(ALL(coors), [](PLL a, PLL b) { return a.second < b.second; });
        for(auto &&ele : coors) {
            ll x, y;
            tie(x, y) = ele;
            ll x_id = get_x_id(x);
            ll top = bit.sum(N + 10);
            ll bottom = N - top - 1;
            cnt += pow2[top] - 1;
            cnt += pow2[bottom] - 1;
            cnt %= mod;
            bit.add(x_id, 1);
        }
    }

    ll ans = N * (pow2[N] - 1);
    DEBUG(make_tuple(ans, cnt));
    ans += mod - cnt;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12160