from fractions import Fraction
import os
from collections import Counter

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]

zeros_cnt = 0
A = []
B = []
for a, b in AB:
    if a == 0 or b == 0:
        zeros_cnt += 1
    else:
        A.append(a)
        B.append(b)

ab = [Fraction(a, b) for a, b in zip(A, B)]
ba = [Fraction(b, a) for a, b in zip(A, B)]

counts = Counter(ba)
ans = 1
nandemo = 0
for f, cnt in Counter(ab).items():
    if counts[-f] == 0:
        nandemo += cnt
    else:
        if f > 0:
            ans *= pow(2, cnt, MOD) + pow(2, counts[-f], MOD) - 1
            ans %= MOD
ans = ans * pow(2, nandemo, MOD) - 1
ans *= zeros_cnt + 1
ans %= MOD
print(ans)
