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 (s == 1 && c == 0) || (!ans[s - 1].nil? && ans[s - 1] != c)
    puts -1
    exit
  end
  ans[s - 1] = c
end
ans = ans.map(&:to_i)
ans[0] = 1 if ans == Array.new(n, 0)
puts ans.join("")