import sys
from math import gcd
input = sys.stdin.readline
n = int(input())
fish = dict()
zero = 0
for i in range(n):
    a, b = map(int, input().split())
    if a == 0:
        if b == 0:
            zero += 1
            continue
        else:
            b = -1
    elif b == 0:
        a = 1
    else:
        g = gcd(a, b)
        a //= g
        b //= g
        if a < 0 and b < 0:
            a = -a
            b = -b
        elif b < 0:
            a = -a
            b = -b

    if (a, b) not in fish:
        fish[(a, b)] = 1
    else:
        fish[(a, b)] += 1

ans = 1
pair = []
mod = 10**9+7
while fish:
    key, value = fish.popitem()
    a, b = key
    if a < 0:
        if (b, -a) in fish:
            pair.append((value, fish[(b, -a)]))
            fish.pop((b, -a))
        else:
            ans *= pow(2, value, mod)
    elif b == 0:
        if (0, -1) in fish:
            pair.append((value, fish[(0, -1)]))
            fish.pop((0, -1))

    else:
        if (-b, a) in fish:
            pair.append((value, fish[(-b, a)]))
            fish.pop((-b, a))
        else:
            ans *= pow(2, value, mod)

for a, b in pair:
    temp = 1
    temp += pow(2, a, mod)-1
    temp += pow(2, b, mod)-1
    ans *= temp
    ans %= mod


print((ans+zero-1)%mod)
