from collections import defaultdict
from functools import reduce
n=int(input())
inf=float('inf')
def lean():
  a,b=map(int,input().split())
  if b==0:
    return inf
  return a/b
leans=sorted([lean() for _ in range(n)])
lean_c=defaultdict(int)
def inv(k):
  if k==0:
    return inf
  if k==inf:
    return 0
  return -1/k
for l in leans:
  lean_c[l]+=1
  lean_c[inv(l)]+=0
neuts=sum(lean_c[l] for l in lean_c if lean_c[inv(l)]==0)
posnegs=[[lean_c[l],lean_c[inv(l)]] for l in lean_c
         if l>0 and lean_c[l]>0 and lean_c[inv(l)]>0]
const=1000000007
def count_posneg(posneg):
  pos,neg=posneg
  return 2**pos%const+2**neg%const-1
print(2**neuts%const*
      reduce(lambda x,y:x*y,(count_posneg(posneg) for posneg in posnegs))
      %const-1)