let scan_int () = Scanf.scanf " %d" (fun x -> x)
let scan_array len read_func = Array.init len (fun _ -> read_func())
let print_int n = Printf.printf "%d\n" n

(* one-based numbering *)
module Fenwick :
  sig
    type t
    val init : (int -> int -> int) -> int -> int -> t
    val add : t -> int -> int -> unit
    val prefix: t -> int -> int
  end =
  struct
    type t = {data: int array; f: (int -> int -> int); n: int; iv: int}
    let init ff len init_val =
      {data = Array.make (len+1) init_val; f = ff; n = len; iv = init_val}
    let add t a w =
      let rec loop x =
        if x > t.n then ()
        else
          let _ = t.data.(x) <- t.f t.data.(x) w in
          let next = x + (x land (-x)) in
          loop next in
      loop a
    let prefix t a =
      let rec loop x ret =
        if x == 0 then ret
        else
          let next = x - (x land (-x)) in
          loop next (t.f ret t.data.(x)) in
      loop a t.iv
  end

module IntMap = Map.Make (struct type t = int let compare = compare end)
let add_map map key n =
  IntMap.add key (n + try IntMap.find key map with Not_found -> 0) map


let () =
  let n = scan_int() and modulo = 998244353 in

  (* pow_two: power of 2 *)
  let pow_two = Array.make (n+1) 1 in
  let _ = 
    for i = 1 to Array.length pow_two -1 do
      pow_two.(i) <- pow_two.(i-1) * 2 mod modulo
    done in
  
  let ans = (pow_two.(n) - 1) * n mod modulo in
  let xmap = ref IntMap.empty and ymap = ref IntMap.empty and ycompress = ref IntMap.empty in
  let xy_list = Array.make n (0,0) in
  let _ =
    for i = 0 to (n-1) do
      let x = scan_int() and y = scan_int() in
      let _ = xmap := add_map !xmap x 1 in
      let _ = ymap := add_map !ymap y 1 in
      xy_list.(i) <- (x, y)
    done in

  (* (s, t) に対して x < s, s < x, y < t, t < y それぞれの集合を引く *)
  let ans = 
    let f key va (retval: (int * int)) =
      let ret, cnt = retval in 
      let ret = ret + modulo - ((pow_two.(cnt) - 1) * va mod modulo) in
      let cnt = cnt + va in
      let ret = ret + modulo - ((pow_two.(n-cnt) - 1) * va mod modulo) in
      ((ret mod modulo), cnt) in
    let xcalc, _ = IntMap.fold f !xmap (0, 0) in
    let ycalc, _ = IntMap.fold f !ymap (0, 0) in
    (ans + xcalc + ycalc) mod modulo in
  
  (* 座標圧縮 *)
  let ysize = 
    let compress key va i =
      let _ = ycompress := add_map !ycompress key (i+1) in (i+1) in
    IntMap.fold compress !ymap 0 in

  (* sort *)
  let _ =
    let comp = 
      fun (x1, y1) (x2, y2) -> if x1 <> x2 then x1 - x2 else y1 - y2 in
    Array.fast_sort comp xy_list in

  (* 重複して取り除かれている (x < s, y < t) などの部分の集合の数を求める *)
  let calc a =
    let ft = Fenwick.init (+) ysize 0 in
    let xhd, yhd = a.(0) in
    let xprev = ref xhd in
    let rec for_loop i ret =
      if i >= n then ret
      else
        let x, y = a.(i) in
        let _ =
          if !xprev <> x then
            let rec inner_loop j =
              if j >= 0 then
                let xj, yj = a.(j) in
                if !xprev == xj then
                  let _ = Fenwick.add ft (IntMap.find yj !ycompress) 1 in
                  inner_loop (j-1) in
            let _ = inner_loop (i-1) in
            xprev := x in
        let yc = IntMap.find y !ycompress in
        let s = Fenwick.prefix ft (yc-1) in
        let t = (Fenwick.prefix ft ysize) - (Fenwick.prefix ft yc) in
        let ret = ret + pow_two.(s) + pow_two.(t) - 2 in
        for_loop (i+1) (ret mod modulo) in
    for_loop 0 0 in
  let ans = (ans + calc xy_list) mod modulo in
  let xy_rev_list = Array.of_list (List.rev (Array.to_list xy_list)) in
  let ans = (ans + calc xy_rev_list) mod modulo in
  print_int ans


Measured memory_bytes: 64252