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)
for i, (A, B) in enumerate(AB):
    g = gcd(A, B)
    A //= g
    B //= g
    if cnt[(-A, -B)] > 0:
        a, b = -A, -B
    elif cnt[(-B, A)] > 0:
        a, b = -B, A
    elif cnt[(B, -A)] > 0:
        a, b = B, -A
    else:
        a, b = A, B
    cnt[(a, b)] += 1
ans = 0
f = 1
p = [None]*len(cnt)
vs = cnt.values()
for i, v in enumerate(vs):
    p[i] = pow(2, v, mod)    
    f = f * p[i] % mod
for i, v in enumerate(vs):
    f = f * pow(p[i], mod-2, mod) % mod
    ans += v * f
    ans %= mod
print(ans)