from collections import defaultdict as dd
MOD = 10**9+7
N=int(input())
ab = [tuple(map(int, input().split())) for i in range(N)]
res = 0
left_dic = dd(int)
center_dic = dd(int)
right_dic = dd(int)
for a,b in ab:
    if a==b or -a==b:
        center_dic[a/b] += 1
    elif a>b:
        left_dic[a/b] += 1
    elif a<b:
        right_dic[b/a] += 1
comp = []
# center
if center_dic[1.0]>0 and center_dic[-1.0]>0:
    comp.append((center_dic[1.0],center_dic[-1.0]))

# left,right
left = sorted(left_dic.keys(),reverse=True)
right = sorted(right_dic.keys())
idx_left = 0
idx_right = 0
S = len(left)
T = len(right)
# left:+, right:-
while 1:
    if idx_left>=S or idx_right>=T:
        break
    l = left[idx_left]
    r = -right[idx_right]
    if l<0 or r<0:
        break
    if l==r:
        comp.append((left_dic[l], right_dic[-r]))
        idx_left += 1
        idx_right += 1
    elif l>r:
        idx_left += 1
    else:
        idx_right += 1
if idx_right<N and idx_left<N:
    left = [-val for val in left if val < 0]
    # left = left[::-1]
    right = [val for val in right if val > 0]
    S = len(left)
    T = len(right)
    idx_left = 0
    idx_right = 0
    while 1:
        if idx_left >= S or idx_right >= T:
            break
        l = left[idx_left]
        r = right[idx_right]
        if l < 0 or r < 0:
            break
        if l == r:
            comp.append((left_dic[-l], right_dic[r]))
            idx_right += 1
            idx_left += 1
        elif l < r:
            idx_left += 1
        else:
            idx_right += 1
res2 = 0
rest = N
buff = 1
for s,t in comp:
    rest -= s+t
    # tmp = s*t
    tmp = (2**(s+t)-2**s-2**t+1)%MOD
    res2 = (res2 + buff*tmp*pow(2,rest,MOD))%MOD
    buff = (2**(s+t)-tmp)%MOD
res2 += 1
res = (pow(2,N,MOD)-res2)%MOD
print(res)
    