n, m = gets.split.map(&:to_i)
arr = m.times.map{gets.split.map(&:to_i)}

num = 'x' * n

arr.each do |a|
  if num[a[0] - 1] == 'x'
    num[a[0] - 1] = a[1].to_s
  else
    if num[a[0] - 1] != a[1].to_s
      puts -1
      exit
    end
  end
end

if num[0] == '0'
  puts -1
  exit
end

puts num.gsub(/x/, '0')