n,m=gets.chomp.split(" ").map(&:to_i)

s = Array.new(m)
c = Array.new(m)

m.times do |i|
  s[i],c[i] = gets.chomp.split(" ").map(&:to_i)
end

ans = Array.new(n,-1)

m.times do |i|
  if ans[s[i]-1] == -1
    ans[s[i]-1] = c[i]
  elsif ans[s[i]-1] != c[i]
    puts "-1"
    exit
  end
end

if ans[0] == 0
  puts -1
  exit
elsif ans[0] == -1
  print 1
else
  print ans[0]
end

ans[1..n-1].each do |x|
  if x == -1
    print 0
  else
    print x
  end
end