import collections
import math

n = int(input())
m = 0
mod = 10 ** 6 + 7
c = []
d = []
frac = {}

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        n -= 1
        m += 1
        continue
    try:
        if a == 0:
            frac['0'] += 1
        elif b == 0:
            frac['inf'] += 1
        else:
            gcd = abs(math.gcd(a, b))
            sign = 1 if a * b > 0 else -1
            a = sign * abs(a) // gcd
            b = abs(b) // gcd
            frac['{}/{}'.format(a, b)] += 1
    except KeyError:
        if a == 0:
            frac['a0'] = 1
        elif b == 0:
            frac['b0'] = 1
        else:
            gcd = abs(math.gcd(a, b))
            sign = a * b // abs(a * b)
            a = sign * abs(a) // gcd
            b = abs(b) // gcd
            frac['{}/{}'.format(a, b)] = 1

def inverse(key):
    if key == 'a0':
        return 'b0'
    elif key == 'b0':
        return 'a0'
    elif key[0] != '-':
        a, b = key.split('/')
        return '-{}/{}'.format(b, a)
    else:
        a, b = key[1:].split('/')
        return '{}/{}'.format(b, a)

for key, value in frac.items():
    if key == 'b0': continue
    if key[0] == '-': continue
    try:
        d.append(frac[inverse(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 = (ans - 1 + m) % mod

print(ans)