from collections import defaultdict

from math import gcd

mod = 1000000007



n = int(eval(input()))

plus = defaultdict(int)

minus = defaultdict(int)

a_0 = 0

b_0 = 0

a_b_0 = 0

xxx = 10 ** 10

for _ in range(n):

    a, b = list(map(int, input().split()))

    if a == 0 or b == 0:

        if a == 0 and b == 0:

            a_b_0 += 1

        elif a == 0:

            a_0 += 1

        else:

            b_0 += 1

        continue

    g = gcd(a, b)

    a //= g

    b //= g

    if a * b < 0:

        minus[(abs(a), abs(b))] += 1

    else:

        plus[(abs(b), abs(a))] += 1



total = 0

lst = []

for num, _ in list(minus.items()):

    a1 = minus[num]

    a2 = plus[num]

    if a1 * a2 != 0:

        total += a1 + a2

        lst.append([a1, a2])

if a_0 > 0 and b_0 > 0:

    total += a_0 + b_0

    lst.append([a_0, b_0])

n -= a_b_0

ans = pow(2, n - total, mod)

for a, b in lst:

    ans = (ans * (pow(2, a, mod) + pow(2, b, mod) - 1)) % mod

ans = (ans - 1 + a_b_0) % mod

    

print(ans)

    

MOD = 10 ** 9 + 7

from math import gcd

from collections import defaultdict



n = int(eval(input()))

plus = defaultdict(int)

minus = defaultdict(int)

zero = [0, 0, 0]

for _ in range(n):

    a, b = list(map(int, input().split()))

    if a * b == 0:

        if a == b == 0:

            zero[0] += 1

        elif a == 0:

            zero[1] += 1

        else:

            zero[2] += 1

        continue

    g = gcd(a, b)

    a //= g

    b //= g

    if a < 0:

        a *= -1

        b *= -1

    if b >= 0:

        s = str(a) + "-" + str(b)

        plus[s] += 1

    else:

        s = str(-b) + "-" + str(a)

        minus[s] += 1



pm = [[zero[1], zero[2]]]

cnt = sum(zero)

for key, value in list(plus.items()):

    if minus[key] != 0:

        pm.append([value, minus[key]])

        cnt += value + minus[key]

        

ans = pow(2, n - cnt, MOD)



for p, m in pm:

    ans *= (pow(2, p, MOD) + pow(2, m, MOD) - 1)

    ans %= MOD

ans += zero[0] - 1

ans %= MOD

print(ans)

from collections import defaultdict
from math import gcd

mod = 1000000007
n = int(eval(input()))
plus = defaultdict(int)
minus = defaultdict(int)
a_0 = 0
b_0 = 0
a_b_0 = 0
xxx = 10**10
for _ in range(n):
    a, b = list(map(int, input().split()))
    if a == 0 or b == 0:
        if a == 0 and b == 0:
            a_b_0 += 1
        elif a == 0:
            a_0 += 1
        else:
            b_0 += 1
        continue
    g = gcd(a, b)
    a //= g
    b //= g
    if a * b < 0:
        minus[(abs(a), abs(b))] += 1
    else:
        plus[(abs(b), abs(a))] += 1
total = 0
lst = []
for num, _ in list(minus.items()):
    a1 = minus[num]
    a2 = plus[num]
    if a1 * a2 != 0:
        total += a1 + a2
        lst.append([a1, a2])
if a_0 > 0 and b_0 > 0:
    total += a_0 + b_0
    lst.append([a_0, b_0])
n -= a_b_0
ans = pow(2, n - total, mod)
for a, b in lst:
    ans = (ans * (pow(2, a, mod) + pow(2, b, mod) - 1)) % mod
ans = (ans - 1 + a_b_0) % mod
print(ans)

MOD = 10**9 + 7
from math import gcd
from collections import defaultdict

n = int(eval(input()))
plus = defaultdict(int)
minus = defaultdict(int)
zero = [0, 0, 0]
for _ in range(n):
    a, b = list(map(int, input().split()))
    if a * b == 0:
        if a == b == 0:
            zero[0] += 1
        elif a == 0:
            zero[1] += 1
        else:
            zero[2] += 1
        continue
    g = gcd(a, b)
    a //= g
    b //= g
    if a < 0:
        a *= -1
        b *= -1
    if b >= 0:
        s = str(a) + "-" + str(b)
        plus[s] += 1
    else:
        s = str(-b) + "-" + str(a)
        minus[s] += 1
pm = [[zero[1], zero[2]]]
cnt = sum(zero)
for key, value in list(plus.items()):
    if minus[key] != 0:
        pm.append([value, minus[key]])
        cnt += value + minus[key]
ans = pow(2, n - cnt, MOD)
for p, m in pm:
    ans *= pow(2, p, MOD) + pow(2, m, MOD) - 1
    ans %= MOD
ans += zero[0] - 1
ans %= MOD
print(ans)

+MOD = 10**9 + 7 +from math import gcd -from math import gcd -mod = 1000000007 -a_0 = 0 -b_0 = 0 -a_b_0 = 0 -xxx = 10**10 +zero = [0, 0, 0] -    if a == 0 or b == 0: -        if a == 0 and b == 0: -            a_b_0 += 1 +    if a * b == 0: +        if a == b == 0: +            zero[0] += 1 -            a_0 += 1 +            zero[1] += 1 -            b_0 += 1 +            zero[2] += 1 -    if a * b < 0: -        minus[(abs(a), abs(b))] += 1 +    if a < 0: +        a *= -1 +        b *= -1 +    if b >= 0: +        s = str(a) + "-" + str(b) +        plus[s] += 1 -        plus[(abs(b), abs(a))] += 1 -total = 0 -lst = [] -for num, _ in list(minus.items()): -    a1 = minus[num] -    a2 = plus[num] -    if a1 * a2 != 0: -        total += a1 + a2 -        lst.append([a1, a2]) -if a_0 > 0 and b_0 > 0: -    total += a_0 + b_0 -    lst.append([a_0, b_0]) -n -= a_b_0 -ans = pow(2, n - total, mod) -for a, b in lst: -    ans = (ans * (pow(2, a, mod) + pow(2, b, mod) - 1)) % mod -ans = (ans - 1 + a_b_0) % mod +        s = str(-b) + "-" + str(a) +        minus[s] += 1 +pm = [[zero[1], zero[2]]] +cnt = sum(zero) +for key, value in list(plus.items()): +    if minus[key] != 0: +        pm.append([value, minus[key]]) +        cnt += value + minus[key] +ans = pow(2, n - cnt, MOD) +for p, m in pm: +    ans *= pow(2, p, MOD) + pow(2, m, MOD) - 1 +    ans %= MOD +ans += zero[0] - 1 +ans %= MOD