from math import gcd
from collections import defaultdict


def cmb(n, r):
    return (fac[n] * pow(fac[r], p - 2, p) * pow(fac[n - r], p - 2, p)) % p


p = 1000000007
fac = [1] * (2 * 10 ** 6 + 1)
for i in range(1, 2 * 10 ** 6 + 1):
    fac[i] = (fac[i - 1] * i) % p


N = int(input())

AB = defaultdict(int)
for i in range(N):
    a, b = map(int, input().split())
    g = gcd(a, b)
    AB[(a // g, b // g)] += 1

bad_pairs_cnt = 0
for a, b in AB:
    bad_pairs_cnt += AB[(a, b)] * (AB.get((-b, a), 0) + AB.get((b, -a), 0))

ans = N
for i in range(2, N + 1):
    b = cmb(N, 2) - bad_pairs_cnt * (N ** (i - 1))
    if b <= 0:
        break
    ans += b
    ans %= p
print(ans)
