#light "off"
open System;;
open System.IO;;

let reader = new StreamReader(new BufferedStream(Console.OpenStandardInput ()))
let writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput ()))

let skipSpaces () = while reader.Peek () <= int ' ' do reader.Read () |> ignore done;;
let read f = skipSpaces (); [|while reader.Peek () > int ' ' do yield char (reader.Read ()) done |] |> System.String |> f;;
let readint () = skipSpaces (); let s = if reader.Peek() = int '-' then (ignore (reader.Read()); -1) else 1 in let mutable ans = 0 in while reader.Peek () > int ' ' do ans <- ans * 10 + (reader.Read () - int '0'); done; s * ans;;
let write (s : string) = writer.Write s;;
let writeln (s : string) = writer.WriteLine s;;


let MOD = 998244353;;
type Mint = Mint of int
  with
    static member (+) (Mint x, Mint y) = Mint (let z = x + y in if z < MOD then z else z - MOD)
    static member (-) (Mint x, Mint y) = Mint (let z = x - y in if z >= 0 then z else z + MOD)
    static member (*) (Mint x, Mint y) = int64 x * int64 y % int64 MOD |> int |> Mint
    override this.ToString() = match this with | Mint x -> x.ToString()
  end;;

type BIT = { dat : int [] }
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module BIT =
  begin
    let create n : BIT = { dat = Array.create (n + 1) 0 }
    let update ({dat=dat} : BIT) (k : int) (v : int) =
      let mutable i = k + 1 in
      while i < Array.length dat do dat.[i] <- dat.[i] + v; i <- i + (i &&& -i) done
    let query ({dat=dat} : BIT) (k : int) : int =
      let mutable i = k in
      let mutable ans = 0 in
      while i > 0 do ans <- ans + dat.[i]; i <- i - (i &&& -i) done;
      ans
  end;;

let N = readint ();;
let X, Y = Array.init N (fun _ -> readint (), readint ()) |> Array.sort |> Array.unzip;;

// Watasi ha Array.distinct no time complexity wo siranai.
// I don't know the time complexity of Array.sort.
let YD = Array.copy Y |> Array.distinct |> Array.sort;;

let where (a : int []) (k : int) : int =
  let mutable l = -1 in
  let mutable r = Array.length a in
  while r - l > 1 do
    let mutable x = (l + r) / 2 in
    if a.[x] >= k then r <- x else l <- x
  done;
  r;;

for i in 0..N-1 do
  Y.[i] <- where YD Y.[i];
done;;

let L = BIT.create (Array.length YD);;
let R = BIT.create (Array.length YD);;

for i in 0..N-1 do BIT.update R Y.[i] 1 done;;

let two = Array.replicate N (Mint 2) |> Array.scan (*) (Mint 1);;
let sub (x : byref<Mint>) (y : Mint) = x <- x - y;;

let mutable ans = two.[N] * (Mint N);;
for i in 0..N-1 do
  BIT.update R Y.[i] (-1);
  let d = BIT.query L Y.[i] in
  let c = BIT.query R Y.[i] in
  let a = i - d in
  let b = (N-1-i-c) in
  sub &ans <| (Mint 1);
  sub &ans <| two.[a] - Mint 1;
  sub &ans <| two.[b] - Mint 1;
  sub &ans <| two.[c] - Mint 1;
  sub &ans <| two.[d] - Mint 1;
  sub &ans <| (two.[a] - Mint 1) * (two.[b] - Mint 1);
  sub &ans <| (two.[b] - Mint 1) * (two.[c] - Mint 1);
  sub &ans <| (two.[c] - Mint 1) * (two.[d] - Mint 1);
  sub &ans <| (two.[d] - Mint 1) * (two.[a] - Mint 1);
  BIT.update L Y.[i] 1;
done;;

printfn "%O" ans;;

reader.Close();;
writer.Close();;