local mfl, mce = math.floor, math.ceil
local mmi, mma = math.min, math.max
local bls, brs = bit.lshift, bit.rshift
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    local cnt = bls(1, i - 1)
    for j = 1, cnt do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.stage = {{}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.stage[stagenum] = {}
  end
  self.stagenum = stagenum
  self.left_stage = {}
  for i = 1, n do
    local sp, sz = 1, bls(1, stagenum - 1)
    while(i - 1) % sz ~= 0 do
      sp, sz = sp + 1, brs(sz, 1)
    end
    self.left_stage[i] = sp
  end
  self.sz_stage = {}
  local tmp, sp = 1, stagenum
  for i = 1, n do
    if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end
    self.sz_stage[i] = sp
  end
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local stagenum = self.stagenum
  local ret = self.emptyvalue
  while left <= right do
    local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])
    local sz = bls(1, stagenum - stage)
    ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])
    left = left + sz
  end
  return ret
end
SegTree.addValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = self.stage[self.stagenum][idx] + value
  for i = self.stagenum - 1, 1, -1 do
    local dst = brs(idx + 1, 1)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
    idx = dst
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local mod = 998244353

local function comp(a, b) return a < b end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local function upper_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if comp(x, ary[1]) then return 1 end
  if not comp(x, ary[num]) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if not comp(x, ary[mid]) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local function bmul(x, y)
  local x0, y0 = x % 31596, y % 31596
  local x1, y1 = mfl(x / 31596), mfl(y / 31596)
  return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod
end
local function badd(x, y)
  return (x + y) % mod
end

local function bsub(x, y)
  return x < y and x - y + mod or x - y
end

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res
end

local function modinv(src)
  return modpow(src, mod - 2)
end

local p2 = {2}
for i = 2, 200010 do p2[i] = badd(p2[i - 1], p2[i - 1]) end
local function getpow2(x)
  if x == 0 then return 1
  else return p2[x] end
end

local n = io.read("*n")
local xs, ys = {}, {}
local idx_by_x = {}
local sorted_x, sorted_y = {}, {}
local ymap = {}
for i = 1, n do
  xs[i], ys[i] = io.read("*n", "*n")
  idx_by_x[i] = i
  sorted_x[i] = xs[i]
  sorted_y[i] = ys[i]
  ymap[ys[i]] = true
end
table.sort(idx_by_x, function(a, b) return xs[a] < xs[b] end)
table.sort(sorted_x)
table.sort(sorted_y)
local y_uniq = {}
for k, _u in pairs(ymap) do
  table.insert(y_uniq, k)
end
table.sort(y_uniq)
local y_uniq_inv = {}
for i = 1, #y_uniq do
  y_uniq_inv[y_uniq[i]] = i
end

local stLeft = SegTree.new(#y_uniq, function(a, b) return a + b end, 0)

-- by x_sorted index
local x_pattern = {}

local x_left_pos = 1
local x_right_pos = 1
for i_x = 1, n do
  local x = sorted_x[i_x]
  if 1 < i_x and sorted_x[i_x - 1] < x then
    for i = x_left_pos, i_x - 1 do
      local y = ys[idx_by_x[i]]
      local yu = y_uniq_inv[y]
      stLeft:addValue(yu, 1)
    end
    x_left_pos = i_x
  end
  while x_right_pos < n and x == sorted_x[x_right_pos + 1] do
    x_right_pos = x_right_pos + 1
  end
  local x_small_count = x_left_pos - 1
  local x_large_count = n - x_right_pos
  local pat_all = bsub(getpow2(n), 1)
  local pat_xsmall = bsub(getpow2(x_small_count), 1)
  local pat_xlarge = bsub(getpow2(x_large_count), 1)

  local src = idx_by_x[i_x]
  local y = ys[src]
  local y_small_count = lower_bound(sorted_y, y) - 1
  local y_large_count = n + 1 - upper_bound(sorted_y, y)
  local pat_ysmall = bsub(getpow2(y_small_count), 1)
  local pat_ylarge = bsub(getpow2(y_large_count), 1)

  local yu = y_uniq_inv[y]
  local x_small_y_small_count = 0
  if 1 < yu then
    x_small_y_small_count = stLeft:getRange(1, yu - 1)
  end
  local pat_x_small_y_small_count = bsub(getpow2(x_small_y_small_count), 1)
  local x_small_y_large_count = 0
  if yu < #y_uniq then
    x_small_y_large_count = stLeft:getRange(yu + 1, #y_uniq)
  end
  local pat_x_small_y_large_count = bsub(getpow2(x_small_y_large_count), 1)

  local v = badd(pat_all, badd(pat_x_small_y_small_count, pat_x_small_y_large_count))
  v = bsub(v, pat_xsmall)
  v = bsub(v, pat_xlarge)
  v = bsub(v, pat_ysmall)
  v = bsub(v, pat_ylarge)
  x_pattern[i_x] = v
end
x_right_pos = n
local stRight = SegTree.new(#y_uniq, function(a, b) return a + b end, 0)
for i_x = n, 1, -1 do
  local x = sorted_x[i_x]
  if i_x < n and x < sorted_x[i_x + 1] then
    for i = x_right_pos, i_x + 1, -1 do
      local y = ys[idx_by_x[i]]
      local yu = y_uniq_inv[y]
      stRight:addValue(yu, 1)
    end
    x_right_pos = i_x
  end
  local src = idx_by_x[i_x]
  local y = ys[src]
  local yu = y_uniq_inv[y]
  local x_large_y_small_count = 0
  if 1 < yu then
    x_large_y_small_count = stRight:getRange(1, yu - 1)
  end
  local pat_x_large_y_small_count = bsub(getpow2(x_large_y_small_count), 1)
  local x_large_y_large_count = 0
  if yu < #y_uniq then
    x_large_y_large_count = stRight:getRange(yu + 1, #y_uniq)
  end
  local pat_x_large_y_large_count = bsub(getpow2(x_large_y_large_count), 1)
  local v = badd(pat_x_large_y_small_count, pat_x_large_y_large_count)
  x_pattern[i_x] = badd(x_pattern[i_x], v)
end
local ret = 0
for i = 1, n do
  ret = badd(ret, x_pattern[i])
end
print(ret)


Measured memory_bytes: 48236