from collections import Counter
n = int(input())

N = 1000000007

def rate(a,b):
    if a==0:
        return (0,1)
    elif b==0:
        return (1,0)
    elif a==b and b==0:
        return (0,0)
    r=1
    a1=a
    b1=b
    while r!=0:
        r=a1%b1
        a1=b1
        b1=r
    return (a//a1 , b//a1)

z =[]

for i in range(n):
    b , c = map(int, input().split())
    z.append(rate(b,c))

c = Counter(z)

k = list(c.keys())
v = list(c.values())


d=[]
e=0

for i in k:
    x,y=i
    if x<0:
        x*=-1
        y*=-1
    if (y*(-1),x) in k:
        t = (y*(-1),x)
        if not (c[t],c[i]) in d:
            d.append((c[i],c[t]))
    else:
        e+=c[i]
e-=c[(0,0)]
ans = 1
for i in d:
    x,y=i
    ans *= pow(2,x,N) + pow(2,y,N)-1
ans*=pow(2,e,N)
print(ans%N-1)
