N, M = gets.split.map{|i|i.to_i}
d = "n" * N
M.times{
    s, c = gets.split
    s = s.to_i - 1
    if d[s] == "n"
        d[s] = c
        next
    end
    if d[s] == c
        next
    end
    d = nil
    break
}
if d
    if d[0] == "n"
        d[0] = "1"
    end
    d.gsub!(/n/, "0")
    if d.match(/^0{2,}$/)
        puts -1
    else
        puts d
    end
else
    puts -1
end
