MOD  = 1000000007i64
POW2 = [1i64]
n = read_line.to_i
n.times do |i|
  POW2 << POW2[-1] * 2 % MOD
end

map = Hash(Tuple(Int64, Int64), Int32).new(0)
ans = 1i64
zero = false
rs = Array.new(n) do
  a, b = read_line.split.map(&.to_i64)
  if a == 0 && b == 0
    zero = true
  else
    gcd = a.gcd(b)
    a //= gcd
    b //= gcd
    map[{a, b}] += 1
  end
  {a, b}
end
n.times do |i|
  v = rs[i]
  count1 = map[v]
  next if count1 == 0
  count1 += map[{-v[0], -v[1]}]
  count2 = map[{-v[1], v[0]}] + map[{v[1], -v[0]}]
  add = POW2[count1] + POW2[count2] - 1
  ans *= add
  ans %= MOD
  map.delete(v)
  map.delete({-v[0], -v[1]})
  map.delete({-v[1], v[0]})
  map.delete({v[1], -v[0]})
end
ans += MOD - 1
if zero
  ans += 1
end
puts ans % MOD
