from sys import stdin
from sys import setrecursionlimit
from queue import deque
import math
setrecursionlimit(10 ** 7)

mod = 10**9+7

dic = {}
dic2 = {}

n = int(stdin.readline().rstrip())
for i in range(n):
    a,b = map(int,stdin.readline().rstrip().split())
    if a == 0 or b == 0:
        if 0 not in dic:
            dic["0"] = 1
            dic2["0"] = 1
        else:
            dic["0"] += 1
            dic2["0"] += 1
    if str(-a/b) in dic:
        dic[str(-a/b)] += 1
    else:
        dic[str(-a/b)] = 1
    if str(b/a) in dic2:
        dic2[str(b/a)] += 1
    else:
        dic2[str(b/a)] = 1

point = 0

for i,j in dic.items():
    if i in dic2:
        point += j*dic2[i]
        point %= mod

point //= 2

print(math.factorial(n)-point)