from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
N=int(input())
AB=[list(map(int,input().split())) for i in range(N)]
mod=10**9+7
idle_max=10**19


for i in range(N):
    a,b=AB[i]
    if a and b:
        n=gcd(a,b)
        if a<0 and n>0:
            n*=-1
        AB[i][0]//=n
        AB[i][1]//=n
#print(AB)
data=defaultdict(int)
c=0
M=0
for i in range(N):
    a,b=AB[i]
    P=M
    if a==0 and b==0:
        continue
    elif a and b==0:
        P-=data[-a]
    elif a==0 and b:
        P-=data[-b*idle_max]
    else:
        P-=data[b*idle_max-a]
    #print(P)
    c+=pow(2,P,mod)
    c%=mod
    if data[a*idle_max+b]==0:
        M+=1
    data[a*idle_max+b]+=1
print(c)
