using DataStructures

parseInt() = parse(Int,readline())
parseLine() = parse.(Int,split(readline()))

const MOD = 10^9+7

function solve()
    N = parseInt()
    cnt = counter(Rational{Int})
    zero = 0
    for i in 1:N
        a, b = parseLine()
        if (a==0 && b==0)
            zero+=1
        else
            inc!(cnt,a//b)
        end
    end

    pow2 = Vector{Int}(undef,N+1)
    pow2[1] = 1
    for i in 2:N+1
        pow2[i] = mod(pow2[i-1]*2,MOD)
    end

    ans = 1
    for (r,c) in cnt
        inv = -1/r
        ans *= mod(pow2[c+1] + pow2[cnt[inv]+1] - 1, MOD)
        reset!(cnt, inv)
        ans %= MOD
    end
    ans += zero-1
    println(ans)
end

solve()