function main()
  
  (N,M) = map(x -> parse(Int,x), split(readline()))
  
  s = zeros(Int,M)
  c = zeros(Int,M)
  ans = ["" for i in 1:N]
  
  for i in 1:M
    (s,c) = split(chomp(readline())," ")
    s = parse(Int,s)
    if ans[s] == "" || ans[s] == c
      ans[s] = c
    else
      ans[1] = "0"
      break
    end
  end

  if ans[1] == "0"
    println(-1)
  else
    for i in 1:N
      if ans[1] == ""
        print("1")
      elseif ans[i] == ""
        print("0")
      else
        print(ans[i])
      end
    end
    println()
  end
  
end

main()