from collections import defaultdict, deque
import math

kMod = 10**9 + 7

N = int(input())
key2count = defaultdict(lambda: [0, 0])

for _ in range(N):
    a, b = map(int, input().split())
    g = math.gcd(a, b)
    a, b = a//g, b//g
    if a < 0:
        a, b = -a, -b
    idx = 0
    if b < 0:
        idx = 1
        a, b = -b, a
    key2count[(a, b)][idx] += 1

print(key2count)
ans = 1
for key, val in key2count.items():
    plus, minus = val
    ans *= (pow(2, plus, kMod) + pow(2, minus, kMod)-1)
    ans %= kMod

print((ans + kMod-1) % kMod)