from fractions import Fraction
MOD = 1000000007
n = int(input())
a = [0] * n
b = [0] * n
fractions = {}
for i in range(n):
    _a, _b = map(int, input().split())
    a[i], b[i] = _a, _b
    if _b == 0 and _a != 0:
        if 0 not in fractions:
            fractions[0] = 0
        fractions[0] += 1
        continue
    if (frac := Fraction(_a, _b)) not in fractions:
        fractions[frac] = 0
    fractions[frac] += 1

revs = {}

for frac in fractions:
    if frac in revs:
        continue
    if frac == Fraction(0):
        rev = 0
        revs[frac] = rev
        revs[rev] = frac
    elif (rev := Fraction(-1) / frac) in revs:
        revs[frac] = rev
        revs[rev] = frac
    else:
        revs[frac] = None

result = 1

checked = set()
for frac, val in fractions.items():
    if frac in checked:
        continue
    checked.add(frac)
    if (rev := revs[frac]) is None:
        result *= pow(2, val, MOD)
        result %= MOD
    else:
        checked.add(rev)
        result *= pow(2, val, MOD) + pow(2, fractions[rev], MOD) - 1
        result %= MOD

print(result - 1)
