import sys
import numpy as np

read = sys.stdin.read
MOD = 10**9 + 7

n = int(input())
ab = np.array(read().split(), dtype=np.float64).reshape([-1,2])
a = ab[:,0]
b = ab[:,1]
c =  a/b
ans = 0
for i in range(n-1):
    ans += pow(2,np.count_nonzero((c*c[i] != -1)[i+1:]), MOD)
    ans %= MOD
ans += 1
ans %= MOD
print(ans)