n,m=gets.split.map(&:to_i)
array = [0]*n
flag = true
m.times do |cnt|
  s,c = gets.split.map(&:to_i)
  s = s - 1
  if (n==1) && (array[s] != c || c == 0 )  && (cnt == 0)
    array[s] = c
    next
  elsif  (n==1) && (array[s] != c )
    flag = false
    break
  elsif n==1
    next
  end    
  if ((array[s] == 0) || array[s] == c) && (s <= (n-1))
    array[s] = c
  else
    flag = false
    break
  end
end
if flag == false || (n!=1 && array[0] == 0)
  puts -1
else
  puts array.join.to_s
end