program example
	implicit none

	integer N,M,i,j
    integer,allocatable :: s(:),c(:),seisuu(:)
	character a(10)
    character(32) b

	a(:)="0"

    read(*,*) N,M
    
    allocate(s(M),c(M),seisuu(N))
    
    do i=1,M
    	read(*,*)s(i),c(i)
	end do
    
    do i=1,M
    
    	if(s(i)==1 .and. c(i)==0) then
        	write(*,*) "-1"
            goto 1
    	end if
        
        if (s(i)>N) then
        	write(*,*) "-1"
            goto 1	
        end if
    
    	do j=i+1,M
        	if(s(i)==s(j) .and. c(i)/=c(j)) then
            	write(*,*) "-1"
                goto 1
            end if
        end do
    end do
    
    do i=1,M
    	do j=1,N
			if (s(i)==j .and. c(i)>=0) then
            	write(b,*) c(i)
        		a(j)=trim(adjustl(b))
            end if
        end do
    end do
    
    write(*,*) adjustl(a(1:N))
                
1 end program example