import sys

def main():
    input = sys.stdin.readline
    mod = pow(10,9)+7
    
    n = int(input())
    key1 = dict()
    key2 = dict()
    
    a_0 = 0
    b_0 = 0
    ab_0 = 0
    
    for i in range(n):
        a, b = map(int, input().split())
        if a == 0 and b == 0:
            ab_0 += 1
            continue
        if a == 0:
            a_0 += 1
            continue
        if b == 0:
            b_0 += 1
            continue
        k1, k2 = abs(a), abs(b)
        if k2 > k1:
            k1, k2 = k2, k1
        while k2%k1:
            k2, k1 = k1, k2%k1
        a //= k1
        b //= k1
        if a*b > 0:
            if a/b in key1:
                key1[a/b] += 1
            else:
                key1[a/b] = 1
        else:
            if abs(b/a) in key2:
                key2[abs(b/a)] += 1
            else:
                key2[abs(b/a)] = 1
    ans = 0
    ans += (ab_0*(n-ab_0)+(ab_0-1)*ab_0//2)%mod
    ans += (a_0*b_0)%mod
    ans %= mod
    
    left = n-(ab_0+a_0+b_0)
    judge = 0
    for k1, v1 in key1.items():
        if k1 in key2:
            v2 = key2[k1]
            left += -v1-v2
            ans += (((v1*v2*pow(2, left, mod))%mod)*(judge+1))%mod
            ans %= mod
            judge += (judge*(v1+v2))%mod
            judge += v1+v2
            judge %= mod
            
    
    ans = ((pow(2, n, mod)-1)+2*mod-ans)%mod
          
    
    print(ans)
    


if __name__ == "__main__":
    main()