from collections import deque

    
    
n = int(input())
a_list = []
b_list = deque()
mod = 10 ** 9 + 7
p = [1] * (n + 1)
for i in range(n):
    p[i + 1] = p[i] * 2 % mod

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 += p[count - num - 1]
    out = out % mod
    count -= 1
    b_list.pop(0)
print(out)



