#include <bits/stdc++.h>

/////////////////////
// Range Add Query //
/////////////////////

template<typename T = int64_t>
class RAddQ {
private:
	std::vector<T> container_;

	void build(const unsigned int array_size)
	{
		unsigned int length{1};
		while (length < array_size)
			length <<= 1;
		container_.resize(2 * length);
	}

public:
	RAddQ(const unsigned int array_size) { build(array_size); }
	RAddQ(const std::vector<T> &array)
	{
		build(array.size());
		std::copy(array.begin(), array.end(), container_.begin() + (container_.size() >> 1));
		for (int i{((int)container_.size() >> 1) - 1}; i > 0; i--)
			container_[i] = container_[2 * i] + container_[2 * i + 1];
	}
	// left,rightは0-indexed、[left, right)の半開区間
	void update(const int left, const int right, const T added)
	{
		for (int left_i{std::max(0, left) + ((int)container_.size() >> 1)}, right_i{std::min((int)container_.size() >> 1, right) + ((int)container_.size() >> 1)};
			left_i < right_i; left_i >>= 1, right_i >>= 1
			)
		{
			if (left_i & 1)
			{
				container_[left_i] += added;
				left_i++;
			}
			if (right_i & 1)
			{
				right_i--;
				container_[right_i] += added;
			}
		}
	}
	// indexは0-indexed
	T get(const int index) const
	{
		T sum{};
		for (int add_place{index + ((int)container_.size() >> 1)}; add_place > 0; add_place >>= 1)
			sum += container_[add_place];
		return sum;
	}
};

////////////
// ModInt //
////////////

// 四則演算の最も左に存在する値がModIntでなければキャストでバグる
// 例えばx = mint * 1000;やx = ModInt(1000) * mint;はいいがx = 1000 * mint;は駄目。
template<int64_t mod_ = 1'000'000'007>
class ModInt {
private:
	int64_t integer_;

public:
	constexpr ModInt(const int64_t initial_number = 0)
		: integer_(initial_number){}
	
	// 四則演算
	constexpr ModInt operator+(const ModInt& operand) const
	{
		ModInt ret{this->integer_ + operand.integer_};
		if (ret.integer_ >= mod_)
			ret.integer_ -= mod_;
		return ret;
	}
	constexpr ModInt operator-(const ModInt& operand) const
	{
		ModInt ret{this->integer_ - operand.integer_};
		if (ret.integer_ < 0)
			ret.integer_ += mod_;
		return ret;
	}
	constexpr ModInt operator*(const ModInt& operand) const
	{
		return {this->integer_ * operand.integer_ % mod_};
	}
	constexpr ModInt operator/(const ModInt& operand) const
	{
		return *this * (operand ^ (mod_ - 2));
	}

	// 累乗
	constexpr ModInt operator^(const int64_t operand) const
	{
		ModInt ret{1}, pow_ope{this->integer_};
		for (int64_t pow{operand}; pow > 0; pow >>= 1)
		{
			if (pow & 1) ret *= pow_ope;
			pow_ope *= pow_ope;
		}
		return ret;
	}

	// 代入
	constexpr ModInt& operator=(const ModInt& operand)
	{
		this->integer_ = operand.integer_;
		return *this;
	}
	constexpr ModInt& operator+=(const ModInt& operand)
	{
		*this = *this + operand;
		return *this;
	}
	constexpr ModInt& operator-=(const ModInt& operand)
	{
		*this = *this - operand;
		return *this;
	}
	constexpr ModInt& operator*=(const ModInt& operand)
	{
		*this = *this * operand;
		return *this;
	}
	constexpr ModInt& operator/=(const ModInt& operand)
	{
		*this = *this / operand;
		return *this;
	}

	// その他
	constexpr operator int64_t() { return integer_; }

	constexpr ModInt getOne() const
	{
		return ModInt(1ll);
	}
	constexpr ModInt getZero() const
	{
		return ModInt(0ll);
	}
};

using Mint = ModInt<998'244'353>;

Mint calcPow2(int64_t num) { return Mint(2ll) ^ num; }

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<std::pair<int, int>> xy(N);
	for (auto& e: xy) scanf("%d%d", &e.first, &e.second);
	std::sort(xy.begin(), xy.end(), [](auto& a, auto& b) { return a.second < b.second; });
	for (int i{}; i < N; i++)
		xy[i].second = i;
	std::sort(xy.begin(), xy.end());
	for (int i{}; i < N; i++)
		xy[i].first = i;

	// 空集合は人力で一切現れないようにする
	Mint ans((calcPow2(N) - Mint(1ll)) * Mint(N));
	RAddQ<int> leftSeg(N), rightSeg(N);
	// 上下左右
	for (int i{}; i < N; i++)
		ans -= (calcPow2(i) - Mint(1ll)) * Mint(4ll);
	for (int i{}; i < N; i++)
	{
		int lb{leftSeg.get(xy[i].second)};
		ans += (calcPow2(lb) - Mint(1ll)) + (calcPow2(i - lb) - Mint(1ll));
		leftSeg.update(xy[i].second, N, 1);
	}
	for (int i{N - 1}; i >= 0; i--)
	{
		int rb{rightSeg.get(xy[i].second)};
		ans += (calcPow2(rb) - Mint(1ll)) + (calcPow2(N - 1 - i - rb) - Mint(1ll));
		rightSeg.update(xy[i].second, N, 1);
	}
	
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 5888