program main
  implicit none
  integer::N,M
  integer::ANS(3)
  integer::s,c
  integer::i
  read*,N,M
  ANS=-1
  do i=1,M
    read*,s,c
    if(ANS(s)>=0.and.ANS(s)/=c)then
      print"(i0)",-1
      stop
    endif
    if(s==1.and.c==0)then
      print"(i0)",-1
      stop
    endif
    ANS(s)=c
  end do
  do i=1,N
    ANS(i)=max(ANS(i),merge(1,0,i==1))
  end do
  do i=1,N
    write(*,"(i0)",advance="no") ANS(I)
  end do
  write(*,*)
end program main