from fractions import Fraction
from collections import Counter
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

MOD = 10**9+7

def main():
    N,*ab = map(int, read().split())

    ab_zero = 0
    a_zero = 0
    b_zero = 0
    ratio = []
    for a, b in zip(*[iter(ab)]*2):
        if a == 0 and b == 0:
            ab_zero += 1
        elif a == 0:
            a_zero += 1
        elif b == 0:
            b_zero += 1
        else:
            ratio.append(Fraction(a, b))
    
    s = Counter(ratio)

    bad = pow(2, a_zero, MOD) * pow(2, b_zero, MOD) - 1
    bad %= MOD
    for k, v in s.items():
        if - 1 / k in s:
            if s[k] != 0:
                bad *= (pow(2, v, MOD) + pow(2, s[-1/k], MOD) -1) % MOD
                bad %= MOD
                s[- 1 / k] = 0
        else:
            bad *= pow(2, v, MOD)
            bad %= MOD

    ans = bad - 1 + ab_zero
    print(ans)
    

if __name__ == "__main__":
    main()
