N = int(input())
mod = 10 **9 + 7

def equal(item0, item1, delta = 10 ** (-20)):
    if abs(item0 - item1) < delta:
        return True
    else:
        return False
def bigger(item0, item1, delta = 10** (-20)):
    if item0 -item1 > delta:
        return True
    else:
        return False
bit = [1]
for k in range(N):
    bit.append(bit[-1]*2%mod)


AB = []
BA = []
zero = 0
from bisect import insort
for _ in range(N):
    A, B = map(int, input().split())
    if A*B == 0:
        if A == 0 and B == 0:
            zero += 1
        elif A == 0 and B != 0:
            AB = [0] + AB
        else:
            BA = [0] + BA
    elif A*B > 0:
        insort(AB, A/B)
    else:
        insort(BA, -B/A)
def make_count(list):
    k = 0
    lis = []
    while k < len(list):
        cnt = 1
        while k+1 < len(list):
            if list[k]==list[k+1]:
                cnt += 1
                k += 1
                continue
            else:
                break
        lis.append([list[k], cnt])
        k += 1
    return lis

AB = make_count(AB)
BA = make_count(BA)
from collections import deque
AB = deque(AB)
BA = deque(BA)
ans = 1 #all pattern
flag = True
pair = []
if len(AB) == 0:
    print(bit[N-zero]+zero-1)
    exit()
if len(BA) == 0:
    print(bit[N-zero]+ zero -1)
    exit()


while True:
    if flag:
        a = AB.popleft()
        b = BA.popleft()
    flag = False
    if a[0]== b[0]:
        pair.append([a[1], b[1]])
        if AB:
            a = AB.popleft()
        if BA:
            b = BA.popleft()
    elif a[0]>b[0]:
        if BA:
          	pair.append([0,b[1]])
            b = BA.popleft()
            continue
        elif AB:
          	pair.append([a[1],0])
            a = AB.popleft()
            continue
        else:
            break
    else:
        if AB:
          	pair.append([a[1], 0])
            a = AB.popleft()
            continue
        elif BA:
          	pair.append([0, b[1])
            b = BA.popleft()
        else:
            break
ans = 1
for item in pair:
    ans *= pow(2, item[0], mod) + pow(2, item[1], mod) -1
    ans %= mod
ans += zero-1
ans %= mod
print(ans)


