from fractions import Fraction
import math
n = int(input())
vector_cnt_dict = dict()

for i in range(n):
    tmp1,tmp2 = map(int,input().split())
    if tmp2 != 0:
        a = Fraction(tmp1,tmp2)
        if a in vector_cnt_dict.keys():
            vector_cnt_dict[a] += 1
        else:
            vector_cnt_dict[a] = 1
    else:
        if (1,0) in vector_cnt_dict.keys():
            vector_cnt_dict[(1,0)] += 1
        else:
            vector_cnt_dict[(1, 0)] = 1

cnt = 1
neutral = 0
#dictのすべてのキーに対して、分母と分子を入れ替えて-1をかけたキーがあればその数分引いて、全数を足し合わせる

for k,v in vector_cnt_dict.items():
    if k != (1,0) and  k != Fraction(0,1):
        if Fraction(k.denominator*(-1),k.numerator) in vector_cnt_dict.keys():
            print(2 **v , 2**vector_cnt_dict[Fraction(k.denominator*(-1),k.numerator)])
            cnt *= (2**v) + (2**vector_cnt_dict[Fraction(k.denominator*(-1),k.numerator)] ) -1
        else:
            neutral += v
    else:
        neutral += v
cnt = math.sqrt(cnt)

print(int(((2**neutral * cnt)-1) % 1000000007))