N, M = gets.split.map(&:to_i)
s, c = [], []

M.times do
  _s, _c = gets.split.map(&:to_i)
  s << _s
  c[_s - 1] = _c
end

# 1桁目が存在しない場合はNG
if s.none? { |_s| _s == 1 }
  puts -1

  exit
end

# 1桁目が0の場合はNG
if s.find { |_s| _s == 1 && c[_s - 1].zero? }
  puts -1

  exit
end

puts c.map { |_c| _c ? _c : 0 }.join
