n = int(input())
mod = 10**9 + 7

a0,b0 = 0,0
count = {}

for _ in range(n):
  a,b = map(int,input().split())
  if a==b==0:
    n-=1
  elif a==0:
    a0 += 1
  elif b==0:
    b0 += 1
  elif (a,b) in count:
    count[(a,b)] +=1
  elif (-a,-b) in count:
    count[(-a,-b)] += 1
  else:
    count[(a,b)] = 1

queue = [(a0,b0)]
checked = set([])
free = 0
for a,b in count:
  if (a,b) in checked:
    continue
  if (-b,a) in count or (b,-a) in count:
    c = count[(-b,a)] if (-b,a) in count else count[(b,-a)]
    queue.append((count[(a,b)], c))
    checked.add((a,b))
    checked.add((-b,a))
    checked.add((b,-a))
  else:
    free += count[(a,b)]



div = []  
for i in range(n+1):
  div.append(pow(i,mod-2,mod))
hist = {}
def comb_all(i):
  if i in hist:
    return hist[i]
  else:
    res = 1
    cmb = 1
    for j in range(1,i+1):
      
      
      cmb *= (i-j+1) * div[j]
      cmb %= mod
      res += cmb
    hist[i] = res
    return res

ans = 1
while queue:
  c1,c2 = queue.pop(-1)
  if c1==c2==0:
    continue
  ans = ans * comb_all(c1) + ans * comb_all(c2)
  ans %= mod
ans *= comb_all(free)
ans %= mod
print(ans)
  