// Original C++ solution (slower):
#include <bits/stdc++.h>



int main() {

    using namespace std;

    constexpr unsigned long maxN = 200010;

    unsigned long N;

    scanf("%lu", &N);

    array<unsigned long, maxN> perm;

    {

        array<pair<long, long>, maxN> p;

        for(unsigned long i = 0; i < N; ++i)scanf("%lu%lu", &p[i].first, &p[i].second);

        sort(p.begin(), p.begin() + N);

        for(unsigned long i = 0; i < N; ++i)p[i] = {p[i].second, i + 1};

        sort(p.begin(), p.begin() + N);

        transform(p.cbegin(), p.cbegin() + N, perm.begin(), [](auto i){return i.second;});

    }



    constexpr unsigned long MOD = 998244353;

    array<unsigned long, maxN> binary;

    unsigned long n = binary[0] = 1;

    generate(binary.begin() + 1, binary.end(), [&n](){if(n >= MOD)n -= MOD;return n <<= 1;});



    array<unsigned long, maxN> fenwick_tree{};

    auto que = [&fenwick_tree, &N](unsigned long i){

        unsigned long s{0}, j{i};

        while (i) { s += fenwick_tree[i]; i -= i & -i; }

        while (j <= N) { ++fenwick_tree[j]; j += j & -j; }

        return s;

    };



    array<unsigned long, maxN> coef{};

    coef[N] = N + MOD - 4;

    for(unsigned long i = 0; i != N; ++i){

        auto p = perm[i], q = que(p);

        ++coef[q];

        ++coef[i - q];

        ++coef[p - q - 1];

        ++coef[N - i - p + q];

    }



    cout << inner_product(binary.begin(), binary.begin() + N + 1, coef.begin(), 4 + MOD - N) % MOD << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <array>

#include <cstdio>

#include <utility>

#include <algorithm>

#include <numeric>



using namespace std;



constexpr unsigned long maxN = 200010;



array<unsigned long, maxN> perm;

    array<unsigned long, maxN> binary;

    array<unsigned long, maxN> coef;

    array<unsigned long, maxN> fenwick_tree;



    unsigned long que(unsigned long i){

        unsigned long s{0}, j{i};

        while (i) { s += fenwick_tree[i]; i -= i & -i; }

        while (j < maxN) { ++fenwick_tree[j]; j += j & -j; }

        return s;

    };





int main() {

    //using namespace std;

   

    unsigned long N;

    scanf("%lu", &N);

   

    {

        array<pair<long, long>, maxN> p;

        for(unsigned long i = 0; i < N; ++i)scanf("%lu%lu", &p[i].first, &p[i].second);

        sort(p.begin(), p.begin() + N);

        for(unsigned long i = 0; i < N; ++i)p[i] = {p[i].second, i + 1};

        sort(p.begin(), p.begin() + N);

        transform(p.cbegin(), p.cbegin() + N, perm.begin(), [](auto i){return i.second;});

    }



    constexpr unsigned long MOD = 998244353;



    unsigned long n = binary[0] = 1;

    generate(binary.begin() + 1, binary.end(), [&n](){if(n >= MOD)n -= MOD;return n <<= 1;});









    coef[N] = N + MOD - 4;

    for(unsigned long i = 0; i != N; ++i){

        auto p = perm[i], q = que(p);

        ++coef[q];

        ++coef[i - q];

        ++coef[p - q - 1];

        ++coef[N - i - p + q];

    }



    printf("%lu", inner_product(binary.begin(), binary.begin() + N + 1, coef.begin(), 4 + MOD - N) % MOD);

    return 0;

}


// Fastest known solution for this problem: