def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

N = int(input())
A = dict()
ngs = 0
zi = 0
for i in range(N):
    a,b = map(int,input().split())
    if a == 0 and b != 0:
        a,b = 0,1
    elif b == 0 and a != 0:
        a,b = 1,0
    elif b == 0 and a == 0:
        zi += 1
    else:
        x = gcd(a,b)
        a = a // x
        b = b // x
        if b < 0:
            a,b = -a,-b
    if (a,b) not in A.keys():
        A[(a,b)] = 1
    else:
        A[(a,b)] += 1
    if (b,-a) in A.keys():
        ngs += A[(b,-a)]
 
 
fac = [1,1]
inv = [1,1]
finv = [1,1]
 
MOD = 100000007
for i in range(2,N+1):
    tmp = fac[-1] * i % MOD
    fac.append(tmp)
    tmp = MOD - inv[MOD % i] * (MOD // i) % MOD
    inv.append(tmp)
    tmp = finv[-1] * inv[i] % MOD
    finv.append(tmp)

    ret = 0
N -= zi
# n = 1
ret += N
retlist = [1,N]
ret += ((fac[N] * finv[2] % MOD) * finv[N-2] % MOD - ngs) % MOD
for n in range(3,N+1):
    tmp = (fac[N] * finv[n] % MOD) * finv[N-n] % MOD
    tmp2 = (fac[N-2] * finv[n-2] % MOD) * finv[max(N-n-2,1)] % MOD * ngs % MOD
    debug = (tmp - tmp2) % MOD
    retlist.append(tmp)
    ret += debug 
    ret = ret % MOD
print(ret)