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

print(c)
