integer N,K,f(0:21,lshift(1,20)),g(0:21,0:lshift(1,20)),pos,t,i,j,jj,ans,len,tmp,fir
character(lshift(1,20)+1) str
read*,N,K
f=0
g=0
do i=0,N
  read*,str
  do j=0,lshift(1,i)
    f(i,j)=merge(1,0,str(j+1:j+1)=='1')
  end do
end do
do i=1,N
  do j=0,lshift(1,i)
    fir=and(rshift(j,(i-1)),1)
    pos=0
    do while (pos<i .and. AND(rshift(j,(i-pos-1)),1)==fir)
      pos=pos+1
    end do
    g(i,j)=merge(-1,pos,pos==i)
  end do
end do
ans=0
len=0
do i=0,N
  do j=1,n-i
    do jj=0,lshift(1,i+j)-1
      f(i, rshift(jj,j)) = f(i, rshift(jj,j))+f(i+j,jj)
      t=g(j,and(jj,(lshift(1,j)-1)))
      if (t/=-1)then
        tmp=f(i+j-t,OR(lshift(rshift(jj,j),j-t),AND(jj,lshift(1,j-t)-1)))
        f(i+j-t,OR(lshift(rshift(jj,j),(j-t)),AND(jj,lshift(1,j-t)-1)))=tmp+f(i+j,jj)
      endif
     end do
   end do
  do j=lshift(1,i)-1,0,-1
    if (f(i,j)>=K)then
      ans=j
      len=i
    endif
  end do
end do
do i=len,1,-1
  write(*,"(A)",advance='no') char(and(rshift(ans,i-1),1)+ichar('0'))
end do
write(*,*)
end program