;; C - Guess The Number

(defun solve (n sc)
  (let ((buf (make-array n :initial-element nil)))
    (loop for (s . c) in sc
          for prev = (aref buf (1- s))
       do (setf (aref buf (1- s))
                (if (and prev (/= prev c)) 'error c)))
    (if (or (find 'error buf) (eql (aref buf 0) 0))
        -1
        (loop for i below n
          unless (aref buf i)
              do (setf (aref buf i) (if (= i 0) 1 0))
          finally (return (map 'string #'digit-char buf))))))

(let* ((n  (read))
       (m  (read))
       (sc (loop repeat m collect (cons (read) (read)))))
  (princ (solve n sc)))
