n, m = gets.split.map(&:to_i)

num = Array.new(n)

m.times do
    s, c = gets.split.map(&:to_i)
    s -= 1

    if num[s]
        if num[s] != c
            puts -1
            exit
        end
    else
        num[s] = c
    end
    
end

if !num[0] || (n != 1 && num[0] == 0)
    puts -1
else
    puts num.map{|e| e ? e : 0}.join
end
