#!/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)
M.times do |i|
  s = attrs[i+1][0].to_i
  c = attrs[i+1][1].to_i
  if A[s-1] == -1 || A[s-1] > c then
    A[s-1] = c
  end
end
if A[0] == -1 || (A[0] == 0 && N > 1) then
  puts "-1"
else
  puts (A.map{|i| i=0 if i==-1;i}).join
end