from math import gcd

N = int(input())
mod = 1000000007
dic = []
zero = 0
dic.append[[1,0],[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][1] += 1
        continue
    elif(A != 0 and B == 0):
        dic[0][1][0] += 1
        continue

    if(A*B < 0):
        A = (-1) * abs(A)
    else:
        A = abs(A)
    B = abs(B)
    A = int(A/gcd(A,B))
    B = int(B/gcd(A,B))
    for i in range(len(dic)):
        if(A*B < 0):
            if(dic[i][0] == [B,abs(A)]):
                dic[i][1][1] += 1
                break
        else:
            if(dic[i][0] == [A,B]):
                dic[i][1][0] += 1
                break
    else:
        if(A*B < 0):
            dic.append([[B,abs(A)],[0,1]])
        else:
            dic.append([[A,B],[1,0]])

cnt_iso = 0
ans = 1

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

ans *= 2**cnt_iso % mod

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

print(ans)