local n, m = io.read("*n", "*n")
local t = {}
for i = 1, n do
  t[i] = -1
end
local valid = true
for i = 1, m do
  local s, c = io.read("*n", "*n")
  if s == 1 and c == 0 and 1 < n then
    valid = false
  end
  if 0 <= t[s] and t[s] ~= c then
    valid = false
  end
  t[s] = c
end
if not valid then
  print(-1)
else
  for i = 1, n do
    if t[i] == -1 then
      if i == 1 or n == 1 then io.write(1)
      else io.write(0)
      end
    else
      io.write(t[i])
    end
  end
  io.write("\n")
end
