n, m = gets.chomp.split(" ").map(&:to_i)
sc = m.times.map { gets.chomp.split(" ").map(&:to_i) }
ans = Array.new(n, nil)
sc.each do |s, c|
  if ans[s - 1].nil?
    ans[s - 1] = c
  elsif ans[s - 1] != c
    puts "-1"
    exit
  end
end
ans[0] = 1 if ans[0].nil?
if ans[0] == 0 && n > 1
  puts "-1"
  exit
end
puts ans.map(&:to_i).join