n,m=gets.split(' ').map(&:to_i)
number=Array.new(n,-1)
#puts number
flag=1
m.times do
  s,c=gets.split(' ').map(&:to_i)
  if number[s-1]==-1||number[s-1]==c
    number[s-1]=c
  else
    flag=0
    break
  end
end

if n>0&&number[0]==0
  flag=0
end

if number.lenght==number.count(0)
  flag==0
end

if number[0]==-1
  number[0]=1
end

if n>0
  for i in 1..n
    if number[i]==-1
      number[i]=0
    end
  end
end

if flag==0
  puts -1
else
  puts number.join
end
