#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++)
#define rep(i, begin, end) for(int i = int(begin); i < int(end); i++)
#define all(v) v.begin(), v.end()
#define lint long long
auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;};
auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;};
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail){
  std::cerr << " " << head;
  debug_impl(tail...);
}
#define debug(...)\
  std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
  debug_impl(__VA_ARGS__);\
  std::cerr << std::noboolalpha;

template<typename Value, typename BinaryOp>
class segment_tree {
    int                 sz, n, N;
    BinaryOp            op;
    Value               id;
    std::vector<Value>  table;

    auto& op_eq(Value& x, Value y) const { return x = op(x, y); }

    void merge(int u)
      { table.at(u) = op(table.at(2 * u), table.at(2 * u + 1)); }

    Value query_impl(int l, int r, int k, int L, int R) const {
      return l <= L && R <= r
        ? table.at(k)
        : R <= l || r <= L
        ? id
        : op(
          query_impl(l, r, 2 * k, L, (L + R) / 2),
          query_impl(l, r, 2 * k + 1, (L + R) / 2, R)
        );
    }

  public:
    segment_tree(int sz, BinaryOp op, Value id):
      sz    (sz),
      n     (std::pow(2, int(std::log2(2 * sz - 1)))),
      N     (n * 2),
      op    (op),
      id    (id),
      table (N, id)
      {}

    auto& at(int i)       { return table.at(n + i); }

    auto& at(int i) const { return table.at(n + i); }

    auto collect() const {
      auto ret = std::vector<Value>(sz);
      for (auto i = 0; i < sz; i++)
        { ret.at(i) = at(i); }
      return ret;
    }

    auto query(int l, int r) const
      { return query_impl(l, r, 1, 0, n); }

    void build_oneline(int i)
      { for (i += n, i /= 2; i > 0; i /= 2) merge(i); }

    void build()
      { for (auto i = 1; i < n; i++) merge(i); }

    void update (int u, Value val) {
      at(u) = val;
      build_oneline(u);
    }

    void add (int u, Value val) {
      at(u) += val;
      build_oneline(u);
    }
};

template<typename Value, typename BinaryOp>
auto make_segment_tree(int sz, BinaryOp op, Value id)
  { return segment_tree<Value, BinaryOp>(sz, std::move(op), id); }

template <typename T>
std::istream& operator>> (std::istream& is, std::vector<T>& v) {
  for (auto & x : v) is >> x;
  return is;
}

template <typename T>
T inverse(T a, T m) {
  T u = 0, v = 1;
  while (a != 0) {
    T t = m / a;
    m -= t * a; std::swap(a, m);
    u -= t * v; std::swap(u, v);
  }
  assert(m == 1);
  return u;
}
template <typename T>
class modular {
  private:
    int value;
  public:
    constexpr modular() = default;
    constexpr modular(const modular&) = default;
    constexpr modular(modular&&) = default;
    modular& operator=(const modular&) = default;
    modular& operator=(modular&&) = default;

    template <typename U>
    modular (const U& x) {value = normalize(x);}

    template <typename U>
    static auto normalize(const U& x) {
      int v = static_cast<int>(-mod() <= x && x < mod() ? x : x % mod());
      if (v < 0) v += mod();
      return v;
    }

    auto const& operator()() const { return value; }
    template <typename U>
    explicit operator U() const { return static_cast<U>(value); }
    constexpr static auto mod() { return T::value; }

    auto& operator+=(const modular& other) {
      if ((value += other.value) >= mod()) value -= mod();
      return *this;
    }
    auto& operator-=(const modular& other) {
      if ((value -= other.value) < 0) value += mod();
      return *this;
    }
    template <typename U>
    auto& operator+=(const U& other) {return *this += modular(other); }
    template <typename U>
    auto& operator-=(const U& other) {return *this -= modular(other); }
    auto operator-() const { return modular(-value); }
    auto& operator++() {return *this += 1;}
    auto& operator--() {return *this -= 1;}
    auto  operator++(int) {modular result(*this); operator++(); return result;}
    auto  operator--(int) {modular result(*this); operator--(); return result;}

    template <typename U = T>
    auto& operator*=(const modular& rhs) {
      value = normalize(static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value));
      return *this;
    }
    auto& operator/=(const modular& other) {
      return *this *= modular(inverse(other.value, mod()));
    }
};
template <typename T> struct is_modular : std::false_type {};
template <typename T> struct is_modular <modular<T>> : std::true_type{};
template <typename T> constexpr bool is_modular_v = is_modular<T>::value;

template <typename T> bool operator==(const modular<T>& lhs, const modular<T>& rhs) { return lhs.value == rhs.value; }
template <typename T, typename U> bool operator==(const modular<T>& lhs, U rhs) { return lhs == modular<T>(rhs); }
template <typename T, typename U> bool operator==(U lhs, const modular<T>& rhs) { return modular<T>(lhs) == rhs; }

template <typename T> bool operator!=(const modular<T>& lhs, const modular<T>& rhs) { return !(lhs == rhs); }
template <typename T, typename U> bool operator!=(const modular<T>& lhs, U rhs) { return !(lhs == rhs); }
template <typename T, typename U> bool operator!=(U lhs, const modular<T>& rhs) { return !(lhs == rhs); }

template <typename T> modular<T> operator+(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) += rhs; }
template <typename T, typename U> modular<T> operator+(const modular<T>& lhs, U rhs) { return modular<T>(lhs) += rhs; }
template <typename T, typename U> modular<T> operator+(U lhs, const modular<T>& rhs) { return modular<T>(lhs) += rhs; }

template <typename T> modular<T> operator-(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) -= rhs; }
template <typename T, typename U> modular<T> operator-(const modular<T>& lhs, U rhs) { return modular<T>(lhs) -= rhs; }
template <typename T, typename U> modular<T> operator-(U lhs, const modular<T>& rhs) { return modular<T>(lhs) -= rhs; }

template <typename T> modular<T> operator*(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) *= rhs; }
template <typename T, typename U> modular<T> operator*(const modular<T>& lhs, U rhs) { return modular<T>(lhs) *= rhs; }
template <typename T, typename U> modular<T> operator*(U lhs, const modular<T>& rhs) { return modular<T>(lhs) *= rhs; }

template <typename T> modular<T> operator/(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) /= rhs; }
template <typename T, typename U> modular<T> operator/(const modular<T>& lhs, U rhs) { return modular<T>(lhs) /= rhs; }
template <typename T, typename U> modular<T> operator/(U lhs, const modular<T>& rhs) { return modular<T>(lhs) /= rhs; }

template<typename T, typename U>
modular<T> power (const modular<T>& a, U b) {
  assert(b >= 0);
  modular<T> x = a, ret = 1;
  for (; b > 0; b /= 2) {
    if (b % 2 == 1) ret *= x;
    x *= x;
  }
  return ret;
}

template <typename T>
std::string to_string(const modular<T>& a) {
  return std::to_string(a());
}
template <typename T>
auto operator<<(std::ostream& os, const T& a)
  -> std::enable_if_t<is_modular_v<T>, std::ostream&>{
    return os << a();
  }
template <typename T>
auto operator>>(std::istream& is, T& a)
  -> std::enable_if_t<is_modular_v<T>, std::istream&> {
  long long x; is >> x;
  a = T(x);
  return is;
}


using mod_type = int;

struct voriable_mod { static mod_type value; };
mod_type voriable_mod::value;
// mod_type& md = voriable_mod::value;
// using Mint = Modular<voriable_mod>;


constexpr int md = 998244353;
using mint = modular<std::integral_constant<std::decay_t<decltype(md)>, md>>;

template <typename T>
std::ostream& operator<< (std::ostream& os, const std::vector<T>& v) {
  auto n = v.size();
  os << "{";
  for (size_t i = 0; i < n; i++)
    {os << (i > 0 ? "," : "") << v.at(i);}
  return os << "}";
}

template <typename T, typename U>
std::ostream& operator<< (std::ostream& os, const std::pair<T, U>& pair)
  { return os << "(" << pair.first << "," << pair.second << ")"; }

template <typename T, typename U>
std::istream& operator>> (std::iostream& is, std::pair<T, U>& pair)
  { return is >> pair.first >> pair.second; }

template <typename... Args, std::size_t ... Inds>
std::ostream& tuple_output_impl
(
  std::ostream& os,
  const std::tuple<Args...>& tuple,
  std::integer_sequence<std::size_t, Inds...>
)
{
  os << "(";
  (void)std::initializer_list<int>{(
    (void)(os << (Inds > 0 ? "," : "") << std::get<Inds>(tuple)), 0
  )...};
  return os << ")";
}
template <typename... Args>
std::ostream& operator<< (std::ostream& os, const std::tuple<Args...>& tuple)
{
  return tuple_output_impl(os, tuple, std::index_sequence_for<Args...>());
}

template <typename... Args, std::size_t ... Inds>
std::istream& tuple_input_impl
(
  std::istream& is,
  std::tuple<Args...>& tuple,
  std::integer_sequence<std::size_t, Inds...>
)
{
  (void)std::initializer_list<int>{(
    (void)(is >> std::get<Inds>(tuple)), 0
  )...};
  return is;
}
template <typename... Args>
std::istream& operator>> (std::istream& is, std::tuple<Args...>& tuple)
{
  return tuple_input_impl(is, tuple, std::index_sequence_for<Args...>());
}

template < template < typename ... > class Container, typename T >
auto coenumerate(Container< T > const& v) {
  auto n = v.size();
  Container< std::pair< T, int >> ret(n);
  for (std::size_t i = 0; i < n; i++)
    { ret.at(i) = {v.at(i), i}; }
  return ret;
}

template < template < typename ... > class Container, typename T >
auto compress (Container< T > const& v) {
  int n = v.size();
  Container< std::pair< T, int > > pairs(n);
  for (auto i = 0; i < n; i++)
    { pairs.at(i) = {v.at(i), i}; }
  std::sort(pairs.begin(), pairs.end());
  std::vector< int > new_v(n);
  for (auto i = 0; i < n; i++)
    { new_v.at(pairs.at(i).second) = i; }
  return new_v;
}


int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector< int > x(n), y(n);
  rep(i, 0, n)
    { std::cin >> x.at(i) >> y.at(i); }
  x = compress(x);
  y = compress(y);
  auto make_table = [&] (auto&& p) {
    auto sum_tree = make_segment_tree(
      n,
      [](auto x, auto y){ return x + y; },
      0
    );
    std::vector< int > lwr(n), upr(n);
    rep(i, 0, n) {
      auto crr = p.at(i);
      lwr.at(i) = sum_tree.query(0, crr);
      upr.at(i) = sum_tree.query(crr, n);
      sum_tree.add(crr, 1);
    }
    return std::make_pair(lwr, upr);
  };
  std::vector< int > p(n);
  rep(i, 0, n)
    { p.at(x.at(i)) = y.at(i); }
  std::vector< int > a(n), b(n), c(n), d(n);
  std::tie(a, b) = make_table(p);
  std::reverse(all(p));
  std::tie(d, c) = make_table(p);
  std::reverse(all(c));
  std::reverse(all(d));
  auto f = [&] (auto x)
    { return power(mint(2), x); };
  auto cal = [&] (auto a, auto b, auto c, auto d) {
    auto dif =
        f(a) * f(b)
      + f(b) * f(c)
      + f(c) * f(d)
      + f(d) * f(a)
      - f(a)
      - f(b)
      - f(c)
      - f(d)
      + 1;
    // debug(a, b, c, d, dif);
    return f(n) - dif;
  };
  auto ret = mint(0);
  rep(i, 0, n)
    { ret += cal(a.at(i), b.at(i), c.at(i), d.at(i)); }
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 11728