n,m=gets.split.map(&:to_i)
l=[nil]*(n+1)
m.times do |i|
  s,c=gets.split.map(&:to_i)
  if l[s]==nil
    l[s]=c
  elsif l[s]!=c
    puts "-1"
    exit
  end
end
if n==1&&l[1]==0
  puts 0
  exit
end
if l[1]==0
  puts "-1"
  exit
end
l.delete_at(0)
if l[0]==nil
  print 1
else
  print l[0]
end
l.delete_at(0)
l.each do |ll|
  if ll==nil
    print 0
  else
    print ll
  end
end

