n=int(input())
import collections
c=collections.Counter()
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
mod=10**9+7
for _ in range(n):
    a,b=map(int,input().split())
    g=abs(gcd(a,b))
    a//=g
    b//=g
    c[(a,b)]+=1
ans=1
s=set()
for i,j in c:
    if (i,j) not in s:
        s.add((i,j))
        s.add((-i,-j))
        s.add((-j,i))
        s.add((j,-i))
        ans*=(pow(2,c[(i,j)]+c[(-i,-j)],mod)+pow(2,c[(j,-i)]+c[(-j,i)],mod)-1)%mod
print(ans-1)