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

if s[1] == 0 then
  output ||= "-1"
end

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

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