from collections import defaultdict

gcd = lambda a, b: a if b == 0 else gcd(b, a%b)
mod = 10**9+7
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
cnt = defaultdict(int)
ans = 0
for i, (A, B) in enumerate(AB):
    if A == B == 0:
        ans += 1
        continue
    elif B == 0:
        cnt[(1, 0)] += 1
        continue
    elif A == 0:
        cnt[(0, 1)] += 1
        continue
    g = gcd(A, B)
    a = A//g
    b = B//g
    if b < 0:
        cnt[(-a, -b)] += 1
    else:
        cnt[(a, b)] += 1
f = 1
p = defaultdict(int)
ks = list(cnt.keys())
cnt2 = defaultdict(int)
for k in ks:
    a, b = k
    v = cnt[k]
    if v <= 0:
        continue
    if a > 0:
        p[k] = pow(2, v+cnt[-b, a], mod)
        cnt2[k] = (cnt[k], cnt[(-b, a)])
        cnt[(-b, a)] = -1
    else:
        p[k] = pow(2, v+cnt[b, -a], mod)
        cnt2[k] = (cnt[k], cnt[(b, -a)])
        cnt[(b, -a)] = -1
    f = f * p[k] % mod
for k in cnt2:
    f = f * pow(p[k], mod-2, mod) % mod
    ans += (cnt2[k][0]+cnt2[k][1]) * f % mod
    ans %= mod
print(ans)