let rec lower_bound l r p =
  if r <= 1 + l
  then r
  else let m = (l + r) / 2 in
       if p m
       then lower_bound l m p
       else lower_bound m r p

let rec solve rmax rmin bmax bmin xys border =
  if border < max 0 (rmax - rmin) * max 0 (bmax - bmin) then false else
  match xys with
  | [] -> true
  | (x, y) :: rest ->
      solve
        (max x rmax) (min x rmin)
        (max y bmax) (min y bmin) rest border ||
      solve
        (max y rmax) (min y rmin)
        (max x bmax) (min x bmin) rest border

let () = Scanf.scanf "%d\n" @@ fun n ->
  let xys = Array.to_list @@ Array.init n @@ fun _ ->
    Scanf.scanf "%d %d\n" @@ fun x y -> x, y in
  Printf.printf "%d\n" @@ lower_bound (-1) 999999998000000001 @@
  solve 1 1000000000 1 1000000000 xys
