# from collections import deque as dq
# import itertools
import math
# import matplotlib.pyplot as plt
# import networkx as nx
# import numpy as np
import sys
input = sys.stdin.readline


def select_num(a, b, mod=1000000007):
    sum = pow(2, a, mod) + pow(2, b, mod) - 1
    return sum % mod


def dict_count(d, a, b):
    this = a / b
    pair = b / a
    if not d.get(this, False):
        d[this] = {"num": 0, "pair": pair}
    d[this]["num"] += 1


def main():
    MOD = 1000000007
    n = int(input())

    a_div_b = {}
    a0 = b0 = zero = 0
    for i in range(n):
        a, b = map(int, input().split())
        if a == 0 or b == 0:
            if a == b == 0:
                n -= 1
                zero += 1
            elif a == 0:
                a0 += 1
            elif b == 0:
                b0 += 1
            continue

        gcd = math.gcd(a, b)
        a //= gcd
        b //= gcd
        dict_count(a_div_b, a, b)

    ans = 1
    cnt = 0
    # print(a_div_b)
    while a_div_b:
        cnt += 1
        _, inner_dict = a_div_b.popitem()
        a_count = inner_dict["num"]
        pair = inner_dict["pair"] * -1
        b_count = a_div_b.get(pair, {}).get("num")
        # print(f"{a_count = }, {b_count = }\n{ans = }, {_ = }")
        if b_count:
            ans *= select_num(a_count, b_count, MOD)
            ans %= MOD
            cnt -= 1
            del a_div_b[pair]
            # print(f"{_ = }, {a_count = }, {b_count = }\n{ans = }")
    else:
        ans *= select_num(a0, b0, MOD)
        ans *= pow(2, cnt, MOD)
        ans += zero - 1
        ans %= MOD

    # print(f"{a_div_b = }")
    print(ans)


if __name__ == '__main__':
    main()