n, m = gets.split.map(&:to_i)
disignation = []
ans = '-1'
m.times do
  disignation << gets.split.map(&:to_i)
end
model = '0' * n

disignation.each do |d|
  model[d[0]-1] = d[1].to_s
end

if model[0] != '0'
  ans = model
end

puts ans
