   program abc157c
      implicit none
      integer::N,M,i,j
      integer,parameter::k=10
      integer,allocatable,dimension(:)::A
      integer,allocatable,dimension(:)::S,C

      read *,N,M
      if (N==1.and.M==0) then
         print *,'-1'
         stop
      end if
      allocate(A(N))
      A=k
      allocate(S(M),C(M))

      do i=1,M
         read *,S(i),C(i)
         if (S(i)==1.and.C(i)==0) then
            print *,'-1'
            stop
         end if
      end do

      do i=1,M
         do j=i+1,M
            if (S(i)==S(j).and.C(i)/=C(j)) then
               print *,'-1'
               stop
            end if
         end do
      end do

      do i=1,N
         do j=1,M
            A(S(j))=C(j)
         end do
         if (i==1.and.A(i)==k) A(i)=1
         if (i>1.and.A(i)==k) A(i)=0
         write(*,'(I1)',advance='no') A(i)
      end do

      stop

   end program abc157c