from collections import defaultdict
MOD=10**9+7
N=int(input())

def powmod(a,p):
  if p==0:
    return 1
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD

num_dic=defaultdict(int)
zero_num=0
inf_num=0

dp=[-1]*(N+1)
dp[0]=1
for i in range(1,N+1):
  a,b=map(int,input().split())
  if a==0 and b==0:
    dp[i]=dp[i-1]
  elif a==0:
    dp[i]=dp[i-1]+powmod(2,i-1-inf_num)
    dp[i]%=MOD
    zero_num+=1
  elif b==0:
    dp[i]=dp[i-1]+powmod(2,i-1-zero_num)
    dp[i]%=MOD
    inf_num+=1
  else:
    dp[i]=dp[i-1]+powmod(2,i-1-num_dic[-b/a])
    dp[i]%=MOD
    num_dic[a/b]+=1

#print(dp)
print(dp[N]-1)