n = gets.to_i
a, b = Array.new(n) { gets.split.map(&:to_i) }.transpose
mod = 10**9 + 7
h = Hash.new(0)
arr = []
ans = 0

a.zip(b).each do |i, j|
  if i == 0 && j == 0
    ans += 1
  elsif i == 0
    h[[0, 1]] += 1
  elsif j == 0
    h[[-1, 0]] += 1
  else
    gcd = i.gcd(j)
    i *= -1 if j < 0
    h[[i / gcd, j.abs / gcd]] += 1
  end
end

h.each do |(i, j), v|
  if i > 0
    arr << 2**v + 2**h[[-j, i]] - 1
    h.delete([-j, i])
  elsif i < 0
    arr << 2**v + 2**h[[j, -i]] - 1
    h.delete([j, -i])
  else
    arr << 2**v
  end
end

ans = (ans + arr.inject { |i, j| i * j % mod } - 1) unless arr.empty?

puts ans % mod