n, m = gets.split(" ").map(&:to_i)
b = Array.new(m){gets.split(" ").map(&:to_i)}
flag = false
Array((10**(n-1))..((10**n)-1)).each do |i|
  s = i.to_s
  f = true
  b.each do |p|
    if s[p[0]-1].to_i != p[1]
      f = false
      break
    end
  end
  if f
    flag = true
    puts i
    break
  end
end
puts -1 unless flag