n, m = gets.chomp.split.map(&:to_i)
res = Array.new(n, -1)
m.times do
  s, c = gets.chomp.split.map(&:to_i)
  if res[s - 1] != -1 && res[s - 1] != c
    puts "-1"
    exit
  end
  if c == 0 && s - 1 < n - 1
    puts "-1"
    exit
  end
  res[s - 1] = c
end

n.times do |i|
  next if res[i] != -1
  if i == 0
    res[i] = 1
  else
    res[i] = 0
  end
end
puts res.join("")