# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product#accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
def run():
    mod = 1000000007
    N, *AB = map(int, read().split())
    A_B = []
    INF = float('inf')
    zerozero = 0
    for i in range(N):
        a = AB[2*i]
        b = AB[2*i+1]
        if a== 0 and b == 0:
            zerozero += 1
        elif b == 0:
            A_B.append(INF)
        else:
            tmp = math.gcd(a,b)
            A_B.append((a/tmp)/(b/tmp))
    A_B.sort()
    comb_dict = defaultdict(lambda:[0,0])
    for val in A_B:
        if val == INF:
            comb_dict[0][1] += 1
        elif val <= 0:
            comb_dict[val][0] += 1
        elif val > 0:
            comb_dict[-1/val][1] += 1

    ret = 1
    for _, val_list in comb_dict.items():
        a,b = val_list
        if a == 0 or b == 0:
            ret *= pow(2, max(a,b), mod)
        else:
            ret *= pow(2, a, mod) + pow(2, b, mod) - 1
        ret %= mod
    ret += zerozero-1
    print(ret%mod)



if __name__ == "__main__":
    run()