from collections import Counter
n=int(input())
mod = 10**9+7
mem = set()
count = []
def gcd(a,b):
    a_=abs(a)
    b_=abs(b)
    if a == 0 and b == 0:
        return 1
    elif a == 0 or b == 0:
        return max(a_,b_)
    else:
        k=max(a_,b_)%min(a_,b_)
        if k==0:
            return min(a_,b_)
        else:
            return gcd(min(a_,b_),k)

for _ in range(n):
    a,b = map(int,input().split())
    g=gcd(a,b)
    a_=abs(a//g)
    b_=abs(b//g)
    if a*b>=0:
        mem.add((a_,b_))
        count.append(str(a_)+"/"+str(b_))
    else:
        mem.add((-a_,b_))
        count.append(str(-a_)+"/"+str(b_))
        
c=Counter(count)
ans=1
num=0
while mem:
    p,q = mem.pop()
    if p>=0:
        p_=p
        q_=-q
    else:
        p_=abs(p)
        q_=q
    k=str(q_)+"/"+str(p_)
    l=str(p)+"/"+str(q)
    if k in c:
        ans*=2**c[k]+2**c[l]-1
        ans%=mod
        mem.remove((q_,p_))
    else:
        num+=c[l]
ans*=2**num
ans%=mod
print(ans-1)