END { load __FILE__ unless $stdin.eof? }

m = 10**9 + 7
n = gets.to_i
fish = Array.new(n) do
  a, b = gets.split.map!(&:to_i)
  c = a.gcd(b)
  c = -c if b < 0 || b == 0 && a < 0
  c == 0 ? [a, b] : [a / c, b / c]
end.tally

fish_p, fish_m = fish.partition { |(a, b), num| a > 0 }.map!(&:to_h)
zero = fish_m.delete([0, 0]) || 0

prod = 1
sol = 0
fish_p.each do |(a, b), x|
  if (y = fish_m.delete([-b, a]))
    prod *= (1 << x) + (1 << y) - 1
    prod %= m
  else
    sol += x
  end
end
sol += fish_m.values.sum

puts (prod * 2.pow(sol, m) + 2.pow(zero, m) - 2) % m
