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
INF = 1e18+10

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

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

graph = [[] for _ in range(n)]
value_indices = {} # a_b values
for i in range(n):
	if a[i] == 0 and b[i] == 0:
		for j in range(n):
			graph[i].append(j)
			graph[j].append(i)
	else:
		if a[i] == 0:
			a_b = 0
			m_b_a = INF
		elif b[i] == 0:
			a_b = INF
			m_b_a = 0
		else:
			a_b = a[i] / b[i]
			m_b_a = -b[i] / a[i]

		if m_b_a in value_indices:
			for j in value_indices[m_b_a]:
				graph[i].append(j)
				graph[j].append(i)
		value_indices[a_b] = value_indices.get(a_b, []) + [i]

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

def comb(i):
	# layers = []
	cur_layer = [i]
	next_layer = []
	used[i] = True

	chet = 0
	nechet = 0
	is_chet = True
	while len(cur_layer) > 0:
		if is_chet:
			chet += len(cur_layer)
		else:
			nechet += len(cur_layer)
		is_chet = not is_chet
		# 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)
	# 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


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)

