N, M = gets.chomp.split.map(&:to_i)
RESULT = Array.new(N)
M.times do 
    s, c = gets.chomp.split.map(&:to_i)
    current = RESULT[s - 1]
    if !current
        RESULT[s - 1] = c
    elsif current != c
        puts -1
        exit 0
    end
end

if !RESULT[0]
    RESULT[0] = 1
end

puts RESULT.map { |digit| digit || 0 }.join