def solve
  n, m = gets.split.map!(&:to_i)
  arr = []
  ans = []
  (0..(m - 1)).each do |i|
    arr[i] = gets.split.map!(&:to_i)
  end

  (0..(m - 1)).each do |j|
    ans[arr[j][0] - 1] = arr[j][1]
  end

  if ans.length != n
    return -1
  elsif ans.length >= 2 && ans[0] == 0
    return -1
  end
  
  ans.each_with_index do |value, index|
    ans[index] = 0 if value.nil?
  end

  ans.join
end
print solve
