P = 1000000007
def pow(a,n)
	r = 1
	while n > 0
		if n % 2 == 1
			r *= a
			r %= P
		end
		a *= 2
		a %= P
		n /= 2
	end
	r
end
N = gets.to_i
A = Hash.new{0}
N.times{|n|
	a, b = gets.split.map(&:to_i)
	A[Rational(a, b)] += 1
}
keys = A.keys
r = 1
keys.each{|k|
	next unless A[k]
	if A[-1 / k]
		a = pow(2, A[k]) - 1
		b = pow(2, A[-1 / k]) - 1
		r *= a + b + 1
		r %= P
		A[-1 / k] = nil
	else
		r *= pow(2, A[k])
		r %= P
	end
}
puts (r - 1) % P
