MOD = 10 ** 9 + 7
N = gets.to_i
A = []
B = []
R = Hash.new { |h, k| h[k] = [] }

N.times do |i|
  a, b = gets.split.map(&:to_i)

  A << a
  B << b

  if b == 0
    R[Float::INFINITY] << i
  else
    R[Rational(a, b)] << i
  end
end

E = Hash.new { |h, k| h[k] = [] }

N.times do |u|
  a = A[u]
  b = B[u]

  r = (b == 0) ? Float::INFINITY : -Rational(b, a)

  R[r].each do |v|
    E[u] << v
  end
end

tree_id = 0
tree_ids = Hash.new
nums = []

N.times do |i|
  next if tree_ids[i]

  queue = []
  queue << [i, 0]
  colors = Hash.new(0)

  until queue.empty?
    v, c = queue.shift

    next if tree_ids[v]
    tree_ids[v] = tree_id
    colors[c] += 1

    E[v].each do |u|
      queue << [u, (c + 1) % 2]
    end
  end

  cnt = 0

  colors.each_value do |n|
    cnt += n * (n + 1) / 2
  end

  nums << cnt + 1

  tree_id += 1
end

ans = 1

nums.each do |n|
  ans *= n
  ans %= MOD
end

puts ans - 1
