n = int(input())
a_list = []
b_list = []
mod = 10 ** 9 + 7
for _ in range(n):
    a, b = map(int, input().split())
    a_list.append((a * pow(b, mod - 2, mod)) % mod)
    b_list.append((b * pow(a, mod - 2, mod)) % mod)
count = n
out = 0
for aa in a_list:
    num = b_list.count((aa * (-1)) % mod)
    out += pow(2, count - num - 1, mod)
    out = out % mod
    count -= 1
    b_list.pop(0)
print(out)