def main():
    from collections import Counter
    from math import gcd
    n, *ab = map(int, open(0).read().split())
    mod = 10 ** 9 + 7
    ans = pow(2, n, mod) - 1
    d = []

    for i, j in zip(*[iter(ab)] * 2):
        g = gcd(i, j)
        x = [i // g, j // g]
        d.append(x)

    vis = []

    tmp = 0
    for (i, j) in d:
        if [i, j] in vis:
            continue
        if [-j, i] in vis:
            continue
        if [j, -i] in vis:
            continue
        x = d.count([i, j])
        y = d.count([-j, i]) + d.count([j, -i])
        z = n - (x + y)
        if y == 0:
            continue
        i = pow(2, x, mod) - 1
        j = pow(2, y, mod) - 1
        k = pow(2, z, mod)
        tmp += i * j * k
        vis.append([i, j])
        vis.append([-j, i])
        vis.append([j, -i])

    ans -= (tmp // 2)
    tmp %= mod

    print(ans)


if __name__ == '__main__':
    main()
