(defvar N)
(defvar M)
(defvar arr)
(setf N (read)
      M (read)
      arr (make-array (1+ N)
                      :initial-element nil)
      (aref arr 0) 'dummy)

(defun input ()
  (loop with Si
        and Ci
        repeat M do
        (setf Si (read)
              Ci (read))
        (if #1=(aref arr Si)
            (if (/= #1# Ci)
                (return nil))
            (setf #1# Ci))
        finally (return t)))
     
(defun output ()
  (if (null #2=(aref arr 1)) (setf #2# 1))
  (if (and (/= N 1) (zerop #2#))
      (princ -1)
      (loop with x = 0
            repeat N
            do
            (princ (or (aref arr (incf x)) 
                       0 )))))

     

(if (input) 
    (output) 
    (princ -1))