Scanf.scanf "%d" (fun n ->
    let rec gcd a b = if b = 0 then a else gcd b (a mod b) in
    let agcd a b = gcd (abs a) (abs b) in

    let module M = Map.Make (struct type t = int * int let compare = compare end) in

    let rec loop i map a0 b0 c0 d0 e0 =
        if i = n then map, a0, b0, c0, d0, e0 else
            let a, b = Scanf.scanf " %d %d" (fun a b -> a, b) in
            if a = 0 && b = 0 then loop (i + 1) map a0 b0 c0 d0 e0 else
            if a = 0 then loop (i + 1) map (a0 + 1) b0 c0 d0 e0 else
            if b = 0 then loop (i + 1) map a0 (b0 + 1) c0 d0 e0 else
            if a = b then loop (i + 1) map a0 b0 c0 (d0 + 1) e0 else
            if a = -b then loop (i + 1) map a0 b0 c0 d0 (e0 + 1) else
            let g = agcd a b in
            let a = a / g in
            let b = b / g in
            let flag = if a < 0 && b < 0 || a > 0 && b > 0 then 2 else 0 in
            let flag = if a < b then flag + 1 else flag in
            let key = if abs a < abs b then abs a, abs b else abs b, abs a in
            let (ca, cb, cc, cd) = try M.find key map with _ -> 0, 0, 0, 0 in
            let abcd = if flag = 0 then ca + 1, cb, cc, cd else
                       if flag = 1 then ca, cb + 1, cc, cd else
                       if flag = 2 then ca, cb, cc + 1, cd else
                                        ca, cb, cc, cd + 1
            in
            let map = M.add key abcd map in
            loop (i + 1) map a0 b0 (c0 + 1) d0 e0
    in
    let map, a0, b0, c0, d0, e0 = loop 0 M.empty 0 0 0 0 0 in
    let m = 1_000_000_007 in
    let ( +@) a b = (a + b) mod m in
    let ( -@) a b = (((a - b) mod m) + m) mod m in
    let ( *@) a b = (a * b) mod m in

    let powmod a b =
        let rec loop r i acc =
            if i = 0 then acc else
                loop (r *@ r) (i lsr 1) (if i land 1 = 1 then r *@ acc else acc)
        in
        loop a b 1
    in

    let ans1 =
        M.fold (fun (k1, k2) (ca, cb, cc, cd) acc ->
            (powmod 2 ca +@ powmod 2 cd -@ 1) *@ (powmod 2 cb +@ powmod 2 cc -@ 1) *@ acc
        ) map 1
    in
    let ans2 = ans1 *@ (powmod 2 d0 +@ powmod 2 e0 -@ 1) in
    let ans3 = ans2 *@ (powmod 2 a0 +@ powmod 2 b0 -@ 1) in
    Printf.printf "%d\n" (ans3 -@ 1)
)