result = ''
n,m = gets.split(' ').map(&:to_i)
hash = {}
m.times do
  a,b = gets.split(' ').map(&:to_i)
  if hash[a].nil?
    hash[a] = b
  else
    result = -1 if hash[a] != b
  end
end

result = -1 if hash[1] == 0 && n != 1 || hash.keys.max > n

if result == -1
  puts result
else
  1.upto(n) do |i|
    result << hash[i].to_s unless hash[i].nil?
    result << '0' if hash[i].nil? && i != 1
    result << '1' if hash[i].nil? && i == 1
  end
  puts result.to_i
end