MOD = 10**9 + 7

sums = [0]
1.upto(2 * (10**5)) do |i|
  sums << (sums[-1] + i) % MOD
end

N = gets.chomp.to_i
fishs = readlines.map { |line| line.chomp.split.map(&:to_i) }

fishs.reject! { |a, b| a.zero? && b.zero? }
values = [] 
fishs.each do |a, b|
  if a.zero? || b.zero?
    values << 0
    next
  end
  if a * b > 0 
    values << Rational(a, b)
    next
  end
  values << Rational(b, a)
end
group = values.group_by(&:itself).map { |key, value| [key, value.count] }.to_h
keys = group.keys.sort

lower = 0
upper = keys.size - 1

ans = 1
while keys[upper] >= 0 || keys[lower] <= 0
  if keys[upper] <= 0 || keys[upper].abs < keys[lower].abs 
    ans = (ans * (sums[group[keys[lower]]] + 1) ) % MOD
    lower += 1
  elsif keys[lower] >= 0 || keys[upper].abs > keys[lower].abs 
    ans = (ans * (sums[group[keys[upper]]] + 1)) % MOD
    upper -= 1
  else
    ans = (ans * (sums[group[keys[upper]]] + sums[group[keys[lower]]] + 1)) % MOD
    lower += 1
    upper -= 1
  end
end
ans = (ans - 1) % MOD

puts ans

