#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

template <class T1>
class Operators
{
public:
    template <class T2>
    const T1 operator+(const T2& right) const{
        T1 ans = static_cast<const T1&>( *this );
        return ans += right;
    }
    template <class T2>
    const T1 operator-(const T2& right) const{
        T1 ans = static_cast<const T1&>( *this );
        return ans -= right;
    }
    template <class T2>
    const T1 operator*(const T2& right) const{
        T1 ans = static_cast<const T1&>( *this );
        return ans *= right;
    }
    template <class T2>
    const T1 operator/(const T2& right) const{
        T1 ans = static_cast<const T1&>( *this );
        return ans /= right;
    }
    template <class T2>
    const T1 operator%(const T2& right) const{
        T1 ans = static_cast<const T1&>( *this );
        return ans %= right;
    }
    bool operator!=(const T1& right) const{
        const T1& left = static_cast<const T1&>( *this );
        return !(left == right);
    }
    bool operator>(const T1& right) const{
        const T1& left = static_cast<const T1&>( *this );
        return right < left;
    }
    bool operator<=(const T1& right) const{
        const T1& left = static_cast<const T1&>( *this );
        return !(right < left);
    }
    bool operator>=(const T1& right) const{
        const T1& left = static_cast<const T1&>( *this );
        return !(left < right);
    }
};

class Mod : public Operators<Mod>
{
private:
    static const int MOD = 998244353;
    long long a;
public:
    Mod(){
        a = 0;
    }
    Mod(long long x){
        a = (x % MOD + MOD) % MOD;
    }
    Mod& operator+=(const Mod& x){
        a = (a + x.a) % MOD;
        return *this;
    }
    Mod& operator-=(const Mod& x){
        a = (a - x.a + MOD) % MOD;
        return *this;
    }
    Mod& operator*=(const Mod& x){
        a = (a * x.a) % MOD;
        return *this;
    }
    Mod& operator/=(const Mod& x){ // フェルマーの小定理、MODが素数である場合のみ有効
        int b = MOD - 2;
        long long c = x.a;
        while(b > 0){
            if(b & 1){
                a *= c;
                a %= MOD;
            }
            c *= c;
            c %= MOD;
            b >>= 1;
        }
        return *this;
    }
    bool operator==(const Mod& x) const{
        return a == x.a;
    }
    long long getValue(){
        return a;
    }
};

class BinaryIndexedTree
{
private:
    int n;
    vector<int> data;
public:
    // コンストラクタ
    BinaryIndexedTree(int n){
        this->n = n;
        data.assign(n+1, 0);
    }
    // k番目の要素にxを加算する
    void add(int k, int x){
        ++ k;
        while(k <= n){
            data[k] += x;
            k += k & -k;
        }
    }
    // 区間[0,k)の総和を返す
    int sum(int k){
        int ret = 0;
        while(k > 0){
            ret += data[k];
            k -= k & -k;
        }
        return ret;
    }
    // 区間[a,b)の総和を返す
    int sum(int a, int b){
        return sum(b) - sum(a);
    }
};

Mod power(Mod a, int b)
{
    Mod ret = 1;
    Mod tmp = a;
    while(b > 0){
        if(b & 1)
            ret *= tmp;
        tmp *= tmp;
        b >>= 1;
    }
    return ret;
}

long long solve(const vector<int>& y)
{
    int n = y.size();
    BinaryIndexedTree left(n), right(n);
    for(int i=0; i<n; ++i)
        right.add(i, 1);

    Mod ans = (power(2, n) - 1) * n;
    for(int x=0; x<n; ++x){
        right.add(y[x], -1);

        ans -= power(2, x) - 1;
        ans -= power(2, n-1-x) - 1;
        ans -= power(2, y[x]) - 1;
        ans -= power(2, n-1-y[x]) - 1;

        ans += power(2, left.sum(0, y[x])) - 1;
        ans += power(2, left.sum(y[x]+1, n)) - 1;
        ans += power(2, right.sum(0, y[x])) - 1;
        ans += power(2, right.sum(y[x]+1, n)) - 1;

        left.add(y[x], 1);
    }
    return ans.getValue();
}

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    map<int, int> mx, my;
    for(int i=0; i<n; ++i){
        cin >> x[i] >> y[i];
        mx[x[i]];
        my[y[i]];
    }
    auto it1 = mx.begin();
    auto it2 = my.begin();
    for(int i=0; i<n; ++i){
        it1->second = i;
        it2->second = i;
        ++ it1;
        ++ it2;
    }

    vector<int> y2(n);
    for(int i=0; i<n; ++i)
        y2[mx[x[i]]] = my[y[i]];
    cout << solve(y2) << endl;

    return 0;
}


Measured memory_bytes: 22912