import math

N = int(input())
mod = 1000000007
dic = {} #{[2,3]:[正の数,負の数]}
zero = 0
dic[0,1] = [0,0]

#辞書登録
for i in range(N):
    A,B = list(map(int,input().split()))

    if(A == 0 and B == 0):
        zero += 1
        continue
    elif(A == 0 and B != 0):
        dic[[0,1]][0] += 1
        continue
    elif(A != 0 and B == 0):
        dic[[0,1]][1] += 1
        continue

    if(A*B < 0):
        A = (-1) * abs(A)
    else:
        A = abs(A)
    B = abs(B)
    As /= gcd(A,B)
    Bs /= gcd(A,B)
    if(A*B < 0):
        if([B,abs(A)] in dic):
            dic[[B,abs(A)]][1] += 1
        else:
            dic[[B,abs(A)]] = [0,1]
    else:
        if([A,B] in dic):
            dic[[A,B]][0] += 1
        else:
            dic[[A,B]] = [1,0]

cnt_iso = 0
ans = 1

#ペアになってない数
for key in dic.key:
    if(key[0] == 0):
        cnt_iso += key[1]
    elif(key[1] == 0):
        cnt_iso += key[1]

ans *= 2**cnt_iso % mod

for key in dic.key:
    if(key[0] != 0 and key[1] != 0):
        ans *= (2**key[0] + 2**key[1]) % mod

print(ans)