import sys
input = sys.stdin.readline

N=int(input())
mod=10**9+7

S=[tuple(map(int,input().split())) for i in range(N)]

from collections import Counter
from fractions import Fraction
C=Counter()

for a,b in S:
    if a==0 and b==0:
        continue
    if b!=0:
        C[Fraction(a,b)]+=1
    else:
        C[float("inf")]+=1
    
ANS=0

#print(C)
P=[]

for x in list(C.keys()):
    if x!=float("inf") and x!=Fraction(0,1):
        n=x.numerator
        d=x.denominator

        P.append((C[x],C[Fraction(-d,n)]))
        C[x]=0
        C[Fraction(-d,n)]=0
    else:
        P.append((C[float("inf")],C[(0,1)]))
        C[float("inf")]=0
        C[(0,1)]=0

ANS=1
for x,y in P:
    if x==0 and y==0:
        continue
    else:
        #print(x,y,pow(2,x,mod)+pow(2,y,mod)-1)
        ANS=ANS*(pow(2,x,mod)+pow(2,y,mod)-1)%mod

print((ANS-1)%mod)
    
