import collections
import fractions

n = int(input())
mod = 10 ** 6 + 7
c = []
d = []

frac = {}

for _ in range(n):
    a, b = map(int, input().split())
    try:
        if b == 0: frac[float('inf')] += 1
        else: frac[fractions.Fraction(a, b)] += 1
    except KeyError:
        if b == 0: frac[float('inf')] = 1
        else: frac[fractions.Fraction(a, b)] = 1

for key, value in frac.items():
    if -1 <= key < 1: continue
    try:
        if key == 0:
            d.append(frac[float('inf')])
        elif key == float('inf'):
            d.append(fractions.Fraction())
        else:
            d.append(frac[-1 / key])
        c.append(value)
    except KeyError:
        continue

ans = pow(2, n - sum(c) - sum(d), mod)
for i, j in zip(c, d):
    tmp = (pow(2, i, mod) + pow(2, j, mod) - 1)
    ans = (ans * (pow(2, i, mod) + pow(2, j, mod) - 1)) % mod
ans -= 1

print(ans)