n, m = gets.split(" ").map(&:to_i)
s = {}
m.times do |i|
  x, y = gets.split(" ").map(&:to_i)
  if (not s[x].nil?) && s[x] != y then
    puts -1
    return
  end
  s[x] = y
end

if s[1] == 0 then
  puts -1
  return
end

n.times do |i|
  if i == 0 then
    print (s[i+1] || 1)
    next
  end

  print (s[i+1] || 0)
end
