using DataStructures

const MOD = 10^9+7
pow2(x) = big(2^x)%MOD

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

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