from math import gcd
from collections import Counter

mod = 1000000007

N = int(input())
F = []

alone = 0

for i in range(N):
    A,B = map(int,input().split())
    if A == 0 and B == 0:
        alone += 1
        continue
    fugou = 1
    if A < 0:
        fugou *= -1
        A *= -1
    if B < 0:
        fugou *= -1
        B *= -1
    if A == 0:
        F.append((0,0,1))
    elif B == 0:
        F.append((0,1,0))
    else:
        C = gcd(A,B)
        F.append((fugou,A//C,B//C))

C = Counter(F)
G = []
for f in F:
    ff,fa,fb = f
    g = (-ff,fb,fa)
    a,b = 1,1
    for i in range(C[f]):
        a *= 2
        a %= mod
    for i in range(C[g]):
        b *= 2
        b %= mod
    c = a + b + mod - 1
    c %= mod
    if c > 1:
        G.append(c)
    C[f] = 0
    C[g] = 0

ans = 1
for g in G:
    ans *= g
    ans %= mod

ans = ans + alone + mod - 1
ans %= mod
print(ans)