n, m = read_line.split.map(&.to_i64)
constraints = Array(Int64 | Nil).new(n, nil)
ok = true
m.times do
  s, c = read_line.split.map(&.to_i64)
  if n != 1 && s == 1 && c == 0
    ok = false
  elsif constraints[s - 1].nil?
    constraints[s - 1] = c
  else
    if constraints[s - 1] != c
      ok = false
    end
  end
end
unless ok
  p -1
else
  if n == 1
    p constraints[0]
  else
    constraints.each_with_index do |c, i|
      if c.nil?
        if i == 0
          constraints[i] = 1_i64
        else
          constraints[i] = 0_i64
        end
      end
    end
    puts constraints.join
  end
end