n, m = gets.split.map(&:to_i)
flag = true
k = Array.new(n, 0)
st = Array.new(n, 0)
m.times {
  s, c = gets.split.map(&:to_i)
  st[s-1] += 1
  k[s-1] = c
}
if n > 1 && k[0] == 0
  puts -1
else
  puts k.join('')
end
