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}
a0 = 0
b0 = 0
N.times{|n|
	a, b = gets.split.map(&:to_i)
	next if a == 0 && b == 0
	if a != 0 && b != 0
		A[Rational(a, b)] += 1
	else
		if a == 0
			a0 += 1
		else
			b0 += 1
		end
	end
}
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 * pow(2, a0) + r * pow(2, b0) - 1) % P
