program guess_the_number
  implicit none
  integer :: n, m, s, i
  character(1) :: c
  character(3) :: x = "   "
  read(*,*) n, m
  do i = 1, m
    read(*,'(i1,x,a)') s, c
    if (x(s:s) == " " .or. x(s:s) == c) then
      x(s:s) = c
      cycle
    end if
    write(*,'(a)') "-1"
    stop
  end do
  do i = 1, n
    if (x(i:i) == " ") then
      x(i:i) = "0"
    end if
  end do
  if (n > 1 .and. x(1:1) == "0") x(1:1) = "1"
  write(*,'(a)') trim(x)
end program guess_the_number