n,m = gets.split.map(&:to_i)
s = []
x = 0
m.times do
  a,b = gets.split.map(&:to_i)
  if a == 1 && b == 0
    x = 1
  else
    s << [a,b]
  end
end

ar = Array.new(n)
s.each do |i|
  if ar[(i[0])-1] == nil
    ar[(i[0])-1] = i[1]
  elsif ar[(i[0])-1] != i[1]
    x = 1
  end
end
if x == 1
  puts "-1"
else
  ans = ""
  for f in 0..(n-1)
    if ar[f] == nil
      if f == 0
        ar[f] = 1
      else
        ar[f] = 0
      end
    end
  end
  ar.each do |j|
    ans += "#{j}"
  end
  puts ans
end
