import sys
import numpy as np
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline

N, *AB = map(int, read().split())
mod = 10 ** 9 + 7
A = np.array(AB[::2], np.int64)
B = np.array(AB[1::2], np.int64)
g = np.gcd(A, B)
A //= g
B //= g
a = A.tolist()
b = B.tolist()
ab = []
answer = 0
for i, j in zip(a, b):
    if i == 0 and j == 0:
        answer += 1
        continue
    if i == 0:
        j = -1
    if j == 0:
        i = 1
    if i < 0:
        ab.append((-i, -j))
    else:
        ab.append((i, j))

cnt = Counter(ab)
if len(cnt) != 0 and answer == 0:
    answer = 1

for (i, j), n in cnt.items():
    if j < 0:
        m = cnt[(-j, i)]
    else:
        m = cnt[(j, -i)]
    if m == -1:
        continue
    if m != 0:
        answer = (answer * (pow(2, n, mod) + pow(2, m, mod) - 1)) % mod
        cnt[(i, j)] = -1
    else:
        answer = (answer * pow(2, n, mod)) % mod

answer -= 1
print(answer)
