parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    N, M = parseMap(split(readline()))

    x = zeros(Int, N)
    flg = 0
    for ii = 1:M
        s, c = parseMap(split(readline()))
        if x[s] != 0 && x[s] != c
            println(-1)
            return
        else
            x[s] = c
        end
    end
    if x[1] == 0 && N != 1
        x[1] = 1
    end
    for ii = 1:N
        print(x[ii])
    end

end

main()