n, m = gets.chomp.split(' ').map(&:to_i)
ans = Array.new(n, nil)

m.times do
  s, c = gets.chomp.split(' ').map(&:to_i)
  if !ans[s-1].nil? && ans[s-1] != c 
    print(-1)
    exit
  else
    ans[s-1] = c
  end
end

ans[0] = 1 if ans[0].nil? && m!=0
if ans[0]==0
  print(-1)
  exit
end
print(ans.map{|e| e ? e : 0}.join.to_i)
