def main():
    import math
    import sys
    input = sys.stdin.readline
    n = int(input())
    mod = 10**9+7
    l1 = []
    l2 = []
    l3 = []
    for i in range(n):
        a,b = map(int,input().split())
        g = math.gcd(a,b)
        a //= g
        b //= g
        
        s2 = [a,b]
        if s2 in l1:
            l3[l1.index(s2)] += 1
        else:
            l1.append(s2)
            l2.append(-1)
            l3.append(1)
            if [-b,a] in l1:
                ind = l1.index([-b,a])
                l2[-1] = ind
                l2[ind] = len(l1)-1
            elif [b,-a] in l1:
                ind = l1.index([b,-a])
                l2[-1] = ind
                l2[ind] = len(l1)-1

    done = set()
    ans = 1
    for i in range(len(l2)):
        if l2[i] < 0:
            ans *= 2
            ans %= mod
        else:
            if l2[i] in done:
                continue
            c1 = l3[i]
            c2 = l3[l2[i]]
            count = (pow(2,c1,mod)+pow(2,c2,mod)-1)%mod
            ans *= count
            ans %= mod
            done.add(i)
            done.add(l2[i])

    print(ans-1)
if __name__ == "__main__":
    main()              
