n, m = gets.chomp.split.map(&:to_i)
ans = []
n.times do |i|
  if i == 0
    ans[i] = 1
  else
    ans[i] = 0
  end
end
de = Array.new(3, false)
m.times do
  s, c = gets.chomp.split.map(&:to_i)
  if s == 1 && c == 0
    p -1
    exit
  end
  if de[s-1]
    if ans[s-1] != c
      p -1
      exit
    end
  end
  ans[s-1] = c
  de[s-1] = true
end
p ans.join('').to_i
