
def get_prods
  sums = [1]
  1.upto(N_MAX) do
    sums << (sums[-1] * 2) % MOD
  end
  sums
end

def classify(fishes)
  a0 = []
  b0 = []
  prod_minus = []
  prod_plus = []

  fishes.each do |fish|
    if fish[0].zero?
      a0 << fish
      next
    elsif fish[1].zero?
      b0 << fish
      next
    end

    gcd = fish[0].gcd(fish[1])
    fish.map! { |f| f / gcd }
    if fish[0] * fish[1] < 0
      fish.map!(&:abs)
      prod_minus << fish.reverse
    else
      fish.map!(&:abs)
      prod_plus << fish
    end
  end
  [a0, b0, prod_minus, prod_plus]
end

MOD = 10**9 + 7
N_MAX = 2 * (10**5)
MINUS = 10**6

prods = get_prods

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

fishes.reject! { |a, b| a.zero? && b.zero? }
a0, b0, prod_minus, prod_plus = classify(fishes)

hash = Hash.new(0)
hash[[0, 0]] = a0.size + b0.size * MINUS

prod_plus.each { |a| hash[a] += 1 }
prod_minus.each { |a| hash[a] += MINUS }

ans = 1

hash.values.each do |a|
  plus = a % MINUS
  minus = a / MINUS
  ans = (ans * (prods[plus] + prods[minus] - 1)) % MOD
end

puts ans - 1