import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
import sys

# sys.stdout.write(str(n)+"\n")
MODULO = 1000000007

n = int(input())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
a_b = [0 for i in range(n)]
m_b_a = [0 for i in range(n)]

for i in range(n):
	a[i], b[i] = map(int, input().split())
	a_b[i] = a[i] / b[i]
	m_b_a[i] = -b[i] / a[i]

# print("a_b", a_b)
# print("m_b_a", m_b_a)

graph = [[] for _ in range(n)]
# rep_size = {}
value_indices = {} # a_b values
# value_size = {} # a_b values
for i in range(n):
	if m_b_a[i] in value_indices:
		for j in value_indices[m_b_a[i]]:
			graph[i].append(j)
			graph[j].append(i)
		# rep_size[rep] += value_size[m_b_a[i]]
		# rep_size[i] = 1
	value_indices[a_b[i]] = value_indices.get(a_b[i], []) + [i]
	 # = value_rep.get(a_b[i], i)
	# value_size[a_b[i]] = value_size.get(a_b[i], 0) + 1

# print("value_indices", value_indices)
# print("graph", graph)

def comb(i):
	layers = []
	cur_layer = [i]
	next_layer = []
	used[i] = True
	while len(cur_layer) > 0:
		layers.append(cur_layer)
		next_layer = []
		for item in cur_layer:
			for child in graph[item]:
				if not used[child]:
					next_layer.append(child)
					used[child] = True
		cur_layer = next_layer.copy()
	# print(layers)
	chet = 0
	nechet = 0
	for i in range(len(layers)):
		if i % 2 == 0:
			chet += len(layers[i])
		else:
			nechet += len(layers[i])
	return pow(2, chet, MODULO) + pow(2, nechet, MODULO) -1
	# return 1


ans = 1
used = [False for _ in range(n)]
for i in range(n):
	if not used[i]:
		if len(graph[i]) == 0:
			used[i]
			ans *= 2
			ans %= MODULO
		else:
			ans *= comb(i)
			ans %= MODULO
print(ans-1)

