n, m = gets.split.map(&:to_i)
s = []
c = []
ans = ['*'] * n
m.times do |i|
  s, c = gets.split.map(&:to_i)
  if s > n
    puts -1
    exit
  end
  if ans[s-1] != '*' && ans[s-1] != c.to_s
    puts -1
    exit
  end
  ans[s-1] = c.to_s
end

if ans[0] == '0'
  puts -1
  exit
end

ans.each_with_index do |n, i|
  if n == '*'
    if i == 0
      ans[i] = 1
    else
      ans[i] = 0
    end
  end
end

puts ans.join.to_i