#include <bits/stdc++.h>


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(x), end(x), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(x), rend(x), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T>
constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args>
constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args>
constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class T>
constexpr T ceiling(const T a, const T b) { return (a + b - 1) / b; }
ll plusMod(ll& a, const ll b) { return a = (a + b) % mod; }
template<typename A, size_t N, typename T>
constexpr void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

template<typename T>
class BIT {
public:
    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;
    }

private:
    int n;
    vector<T> d;

};

template<class T>
struct ModInt {
    T x;
    ModInt(T x = 0) :x(x% mod) {}
    ModInt& operator+=(const ModInt a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(const ModInt a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator*=(const ModInt a) {
        (x *= a.x) %= mod;
        return *this;
    }
    ModInt operator+(const ModInt a) const {
        ModInt res(*this);
        return res += a;
    }
    ModInt operator-(const ModInt a) const {
        ModInt res(*this);
        return res -= a;
    }
    ModInt operator*(const ModInt a) const {
        ModInt res(*this);
        return res *= a;
    }
    ModInt pow(T t) const {
        if (!t) return 1;
        ModInt a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

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

using P = pair<int, int>;
int n;
void solve() {
    mod = 998244353;

    cin >> n;

    vector<P> p(n);
    rep(i, n)
        cin >> p[i].first >> p[i].second;

    all(sort, p);

    rep(i, n)
        p[i].first = i;

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

    vector<int> a(n), b(n), c(n), d(n);
    {
        auto f = [](vector<int>& a, vector<int>& b, vector<P>& p) {
            BIT<int> bit(n);
            rep(i, n) {
                a[i] = bit.sum(p[i].second);
                b[i] = i - a[i];
                bit.add(p[i].second);
            }
        };

        f(a, b, p);
        all(reverse, p);
        f(c, d, p);
        all(reverse, p);
        all(reverse, c);
        all(reverse, d);
    }

    mint ans = 0;
    rep(i, n) {
        vector<int> x{ a[i],b[i],c[i],d[i] };
        vector<mint> pows(4);

        rep(i, 4)
            pows[i] = mint(2).pow(x[i]);

        ans += (pows[0] - 1) * pows[1] * pows[2] * (pows[3] - 1);
        ans += pows[0] * (pows[1] - 1) * (pows[2] - 1) * pows[3];
        ans -= (pows[0] - 1) * (pows[1] - 1) * (pows[2] - 1) * (pows[3] - 1);
        ans += pows[0] * pows[1] * pows[2] * pows[3];
    }

    cout << ans.x << endn;

}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    cout << flush;

    return 0;
}


Measured memory_bytes: 11264