import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))
from fractions import Fraction

N = ii()
ab = li2(N)
mod = 10**9+7

d = defaultdict(int)
for i in range(N):
    if ab[i][1] != 0:
        d[Fraction(ab[i][0], ab[i][1])] += 1
    elif ab[i][0] == ab[i][1] == 0:
        d[10**18+2] += 1
    else:
        d[10**18+1] += 1
d_l = sorted(d.items(), key=lambda x:x[0])

cnt = 1
flag = 0
for k, v in d_l:
    if k == 10**18+2:
        flag = v
        continue
    if k == 0:
        if d[10**18+1]:
            cnt = (cnt * ((2**v-1) + (2**d[10**18+1]-1) + 1)) % mod
        else:
            cnt = ((v+1) * cnt) % mod
    elif k == 10**18+1:
        if d[0.0]:
            continue
        cnt = ((v+1) * cnt) % mod
    elif k > 0:
        if not d[Fraction(-1, k)]:
            cnt = ((v+1) * cnt) % mod
    elif d[Fraction(-1, k)]:
        cnt = (cnt * ((2**v-1) + (2**d[Fraction(-1, k)]-1) + 1)) % mod
    else:
        cnt = ((v+1) * cnt) % mod

print((cnt - 1 + flag) % mod)