n,m = gets.split.map(&:to_i)
s = []
c = []
m.times do |i|
    s[i],c[i] = gets.split.map(&:to_i)
end
result_f = Array.new(n,0)
result = Array.new(n)
for i in 0..(m-1)
    if result_f[s[i]-1] == 0 || result[s[i]-1] == c[i]
        result[s[i]-1] = c[i]
        result_f[s[i]-1] = 1
    else
        puts -1
        exit
    end
end
if n == 2
    if result[0] == nil
        result[0] = 1
    end
    if result[1] == nil
        result[1] = 0
    end
elsif n == 3
    if result[0] == nil
        result[0] = 1
    end
    if result[1] == nil
        result[1] = 0
    end
    if result[2] == nil
        result[2] = 0
    end
end
if (n == 2 && result[0] == 0) || (n == 3 && result[0] == 0)
  puts -1
  exit
end
puts result.join