N, M = gets.split.map(&:to_i)
SC = M.times.map do
  s, c = gets.split.map(&:to_i)
  [s - 1, c]
end

if M > N
  puts -1
  exit 0
end

SC.each do |s, _|
  if s + 1 > N
    puts -1
    exit 0
  end
end

table = {}
SC.each do |s, c|
  if table[s] && table[s] != c
    puts -1
    exit 0
  end
  table[s] = c
end

ans = []
N.times do |i|
  if table[i]
    if i == 0 && table[i] == 0 && N > 1
      puts -1
      exit 0
    else
      ans.push(table[i])
    end
  else
    if i == 0 
      ans.push(1)
    else
      ans.push(0)
    end
  end
end
puts ans.join('')