program Guess_The_Number
    implicit none
    integer(4):: n, m
    integer(4):: i,j,k
    integer(4), allocatable:: number(:), s(:), c(:)
    character(1), allocatable:: c_num(:)
    character(1):: c_

    read*, n, m
    allocate(number(n), s(m), c(m), c_num(n))
    number(:) = -1

    do i=1, m
        read*, s(i), c(i)
    end do

    do i=1, m
        if (number(s(i)) /= -1 .and. number(s(i)) /= c(i)) then
            print*, -1
            stop
        end if

        number(s(i)) = c(i)
    end do

    if (number(1) == 0) then
        print*, -1
        stop
    end if

    if (number(1) == -1)  number(1) = 1
    
    do i=1, n
        if(number(i) == -1) number(i) = 0
        write(c_,'(i0)') number(i)
        c_num(i) = c_
    end do
    
    print*, c_num(:)
    
end program Guess_The_Number