#!/usr/bin/env ruby

require 'pp'
attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

N = attrs[0][0].to_i
M = attrs[0][1].to_i

a = Array.new(N,-1)
x = Array.new(N).map{Array.new()}
M.times do |i|
  s = attrs[i+1][0].to_i - 1
  c = attrs[i+1][1].to_i
  x[s].push c
  if a[s] == -1 || a[s] > c then
    a[s-1] = c
  end
end

valid = true
res = Array.new()
x.each_with_index do |q, index|
  q.uniq!
  if q.length > 1 || (index == 0 && q.first == 0)then
    valid = false
    break
  end
  if index == 0 then
    res.push(q.length == 0 ? 1 : q.first)
  else
    res.push(q.length == 0 ? 0 : q.first)
  end
end
puts valid ? res.join : -1