(defun main ()
  (let* ((n (read))
         (m (read))
         (s (make-array `(,n) :element-type 'character :initial-element #\0))
         (c (make-array `(,(1+ n)) :initial-element nil)))
    (setf (aref s 0) #\1)
    (loop 
          :for i :from 1 :to m
          :do (let ((x (read))
                    (y (read)))
                (when (and (aref c x) (/= (aref c x) y))
                  (format t "-1~%")
                  (return-from main))
                (setf (aref c x) y)
                (setf (aref s (1- x)) (code-char (+ y 48)))
                (when (and (= x 1) (= y 0))
                  (format t "-1~%")
                  (return-from main))))
    (format t "~A~%" s)))
(main)
