nm = gets.chomp.split
n = nm[0].to_i
m = nm[1].to_i

s = Array.new
c = Array.new
m.times do
    input = gets.chomp.split
    s << input[0].to_i
    c << input[1].to_i
end

number = "0"
(n - 1).times do
    number += "0"
end

m.times do |i|
    number[(s[i] - 1)] = c[i].to_s
end

if number.to_i.to_s.length == n
    puts number
else
    puts -1
end