let id x = x

let s = 1000000007
let inv2 = 500000004

let repeat f =
  let rec aux accu = function
    | 0 -> accu
    | n -> aux (f () :: accu) (n - 1) in
  aux []

let ( +% ) a b = let c = a + b in if c > s then c - s else c
let ( -% ) a b = if a > b then a - b else s + a - b
let ( *% ) a b = a * b mod s

let pow k =
  let rec aux accu k = function
  | 0 -> accu
  | n when n mod 2 = 0 -> aux accu (k*%k) (n/2)
  | n -> aux (accu*%k) (k*%k) (n/2) in
  aux 1 k

let inv k = pow k (s-2)

let rec dontimes f = function
  | 0 -> ()
  | n -> f (); dontimes f (n-1)

let () =
  let n = Scanf.scanf "%d\n" id in
  let l = repeat (fun () -> Scanf.scanf "%d %d\n" (fun a b -> (a,b))) n in
  let (maxa, maxb) = List.fold_left (fun (c,d) (a,b) -> (max a c, max d b)) (0, 0) l in
  let factbl = Array.make (2*maxa+2*maxb+1) 1 in
    for i = 1 to 2*maxa+2*maxb do Array.unsafe_set factbl i ((Array.unsafe_get factbl (i-1)) *% i) done;
  let ifactbl = Array.make (2*maxa+2*maxb+1) 0 in
    ifactbl.(2*maxa+2*maxb) <- inv factbl.(2*maxa+2*maxb);
    for i = 2*maxa+2*maxb-1 downto 0 do Array.unsafe_set ifactbl i ((Array.unsafe_get ifactbl (i+1)) *% (i+1)) done;
  let bc n k = factbl.(n) *% ifactbl.(k) *% ifactbl.(n-k) in
  let sal = List.sort (fun (a,_) (c,_) -> compare c a) l in
  let dp = Array.make (1 + 2 * maxb) 0 in
  let update () = for i = 1 to 2 * maxb do Array.unsafe_set dp i (Array.unsafe_get dp i +% Array.unsafe_get dp (i-1)) done in
  let rec solve m = function
     | [] -> dontimes update (maxa+1-m)
     | (a, b) :: tl when a = maxa-m -> dp.(maxb-b) <- (dp.(maxb-b) +% 1); solve m tl
     | sl -> update (); solve (m+1) sl in
  solve 0 sal;
  let rec accum accu = function
    | 0 -> accu +% dp.(0) *% dp.(2*maxb)
    | k -> accum (accu +% (dp.(k) -% dp.(k-1)) *% dp.(2*maxb-k)) (k-1) in
  let sum = accum 0 (2*maxb) in
  let x = List.fold_left (fun x (a,b) -> x +% bc (2*a+2*b) (2*a)) 0 l in
    print_int ((sum -% x) *% inv2)