while''do n,s=io.read():match("(%d+).(.+)")p={}for m=1,#s do for i=1,#s do p[i]=s:sub(i,i)..(p[i]or"")end table.sort(p)end print(p[n+1])end