module FloatMap = Map.Make (struct
  type t = float
  let compare = compare
end)

let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( -^ ) x y = x +^ (m - y)
let ( *^ ) x y = (x * y) mod m

let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let zeros, abs_ =
    List.fold_left (fun (zeros, abs_) (a, b) ->
      if a = 0 || b = 0
      then (1 + zeros, abs_)
      else (zeros, float_of_int a /. float_of_int b :: abs_)) (0, []) @@
    List.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun a b -> a, b in
  let m =
    List.fold_left (fun acc f ->
      FloatMap.update f (fun o -> Some (1 + Option.value ~default:0 o)) @@
      FloatMap.update (-1. /. f) (fun o -> Some (Option.value ~default:0 o)) acc) FloatMap.empty abs_ in
  Printf.printf "%d\n" @@
  Fun.flip ( -^ ) 1 @@
  ( *^ ) (zeros + 1) @@
  FloatMap.fold (fun f n -> ( *^ ) @@
    if f < 0.
    then 1
    else let n' = try FloatMap.find (-1. /. f) m with Not_found -> 0 in (power ( *^ ) 1 2 n +^ power ( *^ ) 1 2 n' -^ 1)) m 1
