You are given a string s.
Among the different substrings of s, print the K-th lexicographically smallest one.
A substring of s is a string obtained by taking out a non-empty contiguous part in s.
For example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.
Also, we say that substrings are different when they are different as strings.
Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.

-----Constraints-----
 - 1 ≤ |s| ≤ 5000
 - s consists of lowercase English letters.
 - 1 ≤ K ≤ 5
 - s has at least K different substrings.

-----Partial Score-----
 - 200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.

-----Input-----
Input is given from Standard Input in the following format:
s
K

-----Output-----
Print the K-th lexicographically smallest substring of K.

-----Sample Input-----
aba
4

-----Sample Output-----
b

s has five substrings: a, b, ab, ba and aba.
Among them, we should print the fourth smallest one, b.
Note that we do not count a twice.

Difficulty: introductory

Starter code:

Solutions:
import sys
stdin=sys.stdin

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
yp=lambda:print('Yes')
np=lambda:print('No')

s=list(sp())
k=ip()

ans=set()

alpa=list(set(s))
alpa.sort()
ch=0
siyou=[]
for i in range(len(alpa)):
  if i<=2:
    siyou.append(alpa[i])
  else:
    break
    
for x in siyou:
  for i in range(len(s)):
    if s[i]==x:
      st=''
      for y in range(i,i+5):
        if y<len(s):
          st+=s[y]
          ans.add(st)
  if len(ans)>k:
    break
  
ans=list(ans)
ans.sort()
print(ans[k-1])
    




s=input()
K=int(input())

if K==1:
  print(sorted(s)[0])
  return
  
topK = sorted(s)[:min(K,len(s))]

indices=[]
for i in range(len(s)):
  if s[i] in topK:indices.append(i)
    
selected=[]
for j in range(len(indices)):
  i = indices[j]
  tmp=[]
  for k in range(min(K,len(s)-i)):
    tmp.append(s[i:i+k+1])
  selected.extend(tmp)
  
selected = sorted(set(selected))

print(selected[K-1])

import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    S = input()
    N = len(S)
    K = int(input())

    places = defaultdict(list)
    for i in range(N):
        places[S[i]].append(i)

    places = sorted(list(places.items()), key=lambda x: x[0])
    words = set()
    for k, v in places:
        for start in v:
            cnt = 0
            for end in range(start + 1, N + 1):
                words.add(S[start:end])
                cnt += 1

                if cnt == 5:
                    break

        if len(words) >= 5:
            break

    words = sorted(words)
    print((words[K - 1]))


def __starting_point():
    main()

__starting_point()

s =input()
k = int(input())

ls = len(s)

res =[]

for i in range(1,k+1):
    for j in range(ls-i+1):
        res.append(s[j:j+i])
        
ress = sorted(list(set(res)))
print(ress[k-1])

s,K = open(0).read().split()
K = int(K)
ss = set()
temp = set([''])
for x in s:
    temp = set([''.join((y,x)) for y in temp if len(y) <= 4])
    ss = ss | temp
    temp.add('')
l = list(ss)
l.sort()
print(l[K-1])

# C - K-th Substring

s = str(input())
K = int(input())

str_list = set()
for i in range(len(s)+1):
    for j in range(i+1, i+K+1):
        if j > len(s):
            break
        str_list.add(s[i:j])

str_list = list(str_list)
str_list.sort()
print((str_list[K-1]))



s = input()
k = int(input())
a = []

for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        if j - i >= 6:
            break
        a.append(s[i:j])

res = sorted(set(a))
print(res[k-1])

s = input()
n = len(s)
k = int(input())
l = set()

for i in range(n):
    for j in range(1, 6):
        if i + j <= n:
            l.add(s[i: i + j])

l = sorted(l)
print(l[k - 1])

s = input()
l = len(s)
k = int(input())
A = set()
for i in range(l):
    for j in range(1, 6):
        if i+j <= l:
            A.add(s[i:i+j])
ANS = sorted(A)
print((ANS[k-1]))


s = input()
k = int(input())

data = set()
for i in range(len(s)):
    for j in range(i, i + k):
        data.add(s[i: j + 1])
data = sorted(data)
print(data[k - 1])

s = input()
K = int(input())

S = set([])
for i in range(len(s)):
    for j in range(i + 1, i + 1 + K):
        # print(f'{s[i:j]=}')
        S.add(s[i:j])
# print(f'{S=}')
# print(f'{sorted(S)=}')
ans = sorted(S)[K - 1]
print(ans)


S = input()
k = int(input())
abc = []
for i in range(len(S)):
    for j in range(1, k+1):
        if i+j <= len(S):
            s = S[i:i+j]
            if not s in abc:
                abc.append(S[i:i+j])
    
abc = sorted(abc)
print((abc[k-1]))


S = input()
N = len(S)
K = int(input())
top_k = []
for i in range(N):
    for j in range(i + 1, min([i + K, N]) + 1):
            st = S[i:j]
            top_k.append(st)
            if len(top_k) > K:
                top_k = list(set(top_k))
                top_k.sort()
                top_k = top_k[:K]
top_k.sort()
print(top_k[-1])

s = input()
k = int(input())
seen = set()
i = 1
 
while i<=k:
  for j in range(len(s)):
    seen.add(s[j:j+i])
  i += 1
 
print(sorted(seen)[k-1])

s = input()
k = int(input())

subs = set()
for i in range(len(s)):
    for j in range(i+1, min(i+6, len(s) + 1)):
        sub = s[i:j]
        subs.add(sub)

print((sorted(list(subs))[k-1]))


s = input()
k = int(input())
n = len(s)
subst = set()
for i in range(n):
    for j in range(5):
        subst.add(s[i:i+j+1])
ls = list(subst)
ls.sort()
print((ls[k-1]))


def main():
    s = input()
    K = int(input())
    r = set()
    for i in range(97, 97 + 26):
        for j, v in enumerate(s):
            if v == chr(i):
                for k in range(5):
                    r.add(s[j:j+k+1])
        if len(r) > 5:
            break
    l = list(r)
    l.sort()
    return l[K-1]
print((main()))


# input
s = input()
K = int(input())

# check
case = []
append = case.append
for i in range(1, K + 1):
    for idx in range(0, len(s) - (i - 1)):
        if s[idx:idx + i] not in case:
            append(s[idx:idx + i])
case.sort(reverse=True)

print(case[-K])

# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
S = input().rstrip()
K = int(input())

Ans = []
for k in range(5):
    for i in range(len(S)-k):
        s = S[i:i+k+1]
        if s not in Ans:
            Ans.append(s)

Ans.sort()
print(Ans[K-1])

s=input()
k=int(input())
r=set()

for i in range(1,6):
    for j in range(len(s)-i+1):
        r.add(s[j:j+i])
l=list(r)
l=sorted(l)
print(l[k-1])

import sys
s = input()
K = int(input())

a_list = sorted(set(s))
for i in a_list:
  if K == 1:
    print(i)
    return
  p = []
  for j, x in enumerate(s):
    if x == i:
      p.append(s[j:min(j+K,len(s))])
  p.sort()
  t = K
  for j in range(len(p)):
    if j != len(p) - 1:
      if p[j] == p[j+1][0:len(p[j])]:
        continue
    if len(p[j]) < t:
      t -= len(p[j]) - 1
    else:
      print(p[j][0:t])
      return
  K = t - 1

import sys

sys.setrecursionlimit(10 ** 9)

S = input()
K = int(input())

chars = sorted(set(S))
checked = set()


def dfs(s):
    for c in chars:
        if len(checked) >= K:
            return
        next_s = s + c
        if next_s not in checked and next_s in S:
            checked.add(next_s)
            if len(checked) == K:
                print(next_s)
                return
            elif len(next_s) <= len(S):
                dfs(next_s)


dfs('')


s = input()
k = int(input())
c = set()
for i in range(len(s)):
    for j in range(i+1, i+6):
        c.add(s[i:j])
print((sorted(list(c))[k-1]))


s = input()
k = int(input())
n = len(s)

# print('s',s,'k',k)
c = set()
for i in range(n):
    # print(s[i:i+5])
    t = s[i:i+5]
    for j in range(1,5+1):
        # print(t[:j])
        c.add(t[:j])

c = list(c)
c.sort()
# print(*c,sep='\n')
print((c[k-1]))


import collections

s = input()
k = int(input())
b = collections.Counter(s)
c = sorted(b.items())
con = []
n = 0
while True:
    con.append(c[n][0])
    if len(con) == k:
        break
    for i in range(len(c)):
        check = c[n][0] + c[i][0]
        if check in s:
            con.append(check)
            if len(con) >= k:
                break
            for i_2 in range(len(c)):
                check_2 = check + c[i_2][0]
                if check_2 in s:
                    con.append(check_2)
                    if len(con) >= k:
                        break
                    for i_3 in range(len(c)):
                        check_3 = check_2 + c[i_3][0]
                        if check_3 in s:
                            con.append(check_3)
                            if len(con) >= k:
                                break
                            for i_4 in range(len(c)):
                                check_4 = check_3 + c[i_4][0]
                                if check_4 in s:
                                    con.append(check_4)
                                    if len(con) >= k:
                                        break
    if len(con) >= k:
        break                              
    n +=1
print(con[k-1])

s = input()
k = int(input())
#l = "abcdefghijklmnopqrstuvwxyz"
#print(ord("b")) 97
ans = []
for i in range(len(s)):
    x = 0
    for j in range(5):
        if (i+j<len(s)):
            x += (ord(s[i+j])-96)*10**(8-2*j)
            ans.append((x,s[i:i+j+1]))
ans = list(set(ans))
ans.sort()
#print(ans)
print(ans[k-1][1])

s = list(input())
k =  int(input())
s.append((''))
Dict = {}
dict_keys = []
for left in range(len(s)):
    for right in range(left+1,len(s)):
        string = ''.join(s[left:right])
        if len(string)>k:
            break
        if string not in Dict.keys():
            Dict[string] = True
Dict = sorted(Dict.keys())
print(Dict[k-1])

S = input()
k = int(input())
ss = []
for i in range(len(S)):
    for j in range(i+1, min(i+k+1, len(S)+1)):
        ss.append(S[i:j])

ss = sorted(list(set(ss)))
print(ss[k-1])

s = input()
k = int(input())
c = set()
for i in range(len(s)):
    for j in range(k):
        c.add(s[i:i+j+1])
print((sorted(list(c))[k-1]))


s = input()
n = len(s)
K = int(input())
ans = []
an = set()
for i in range(1,min(5,n)+1):
    for j in range(n-i+1):
        S = s[j:j+i]
        if S not in an:
            ans.append(S)
            an.add(S)
ans.sort()
print(ans[K-1])

S = input()
N = len(S)
K = int(input())
StringList = []
for TSt in range(0,N):
    for TEd in range(TSt+1,TSt+K+1):
        StringList.append(S[TSt:TEd])
SetString = sorted(set(StringList))
print(SetString[K-1])

s = input()
K = int(input())

def substring(S):
    N = len(S)
    ls = []
    for i in range(1,min(6,N+1)):
        for j in range(0,N-i+1):
            ls.append(S[j:j+i])
    setls = set(ls)
    ls = list(setls)
    ls.sort()
    return ls
print(substring(s)[K-1])

s = input()
n = len(s)
k = int(input())
l = set()

for i in range(n):
    for j in range(1, 6):
        if i + j <= n:
            l.add(s[i: i + j])

l = sorted(l)
print((l[k - 1]))


S = input()
K = int(input())
S_len = len(S)
ans = set()
for i in range(0, K+1):
    for j in range(0, S_len):
        if j + i <= S_len:
            t = S[j:j + i]
            if t != '':
                ans.add(t)
ans = list(ans)
ans.sort()
print((ans[K-1]))


s = list(input())
K = int(input())
sub_list = []
for i in range(1, min(K+1, len(s)+1)):
    for j in range(len(s) - i + 1):
        sub = "".join(s[j:j+i])
        if sub not in sub_list:
            sub_list.append(sub)
sub_list.sort()
print(sub_list[K-1])

s=input()
k=int(input())
n=len(s)
r=[]
for right in range(0,n):
  for left in range(right+1, right+k+1):
    r.append(s[right:left])
print(sorted(set(r))[k-1])

def main2():
    S=list(input())
    K=int(input())
    N=len(S)

    P=sorted(S)
    l=[]
    a=[]
    k=0
    while len(l)<=5 and k<N:
        if P[k] not in a:
            a.append(P[k])
            for n in range(N):
                if S[n]==P[k]:
                    for i in range(1,6):
                        if n+i<=N:
                            tmp="".join(S[n:n+i])
                            if tmp not in l:
                                l.append(tmp)
        k+=1
    l.sort()
    print(l[K-1])

def __starting_point():
    main2()
__starting_point()

s = input()
K = int(input())

seq = set()
l = len(s)
for i in range(l):
    for j in range(1, K + 1):
        seq.add(s[i:i + j])

seq = list(seq)
seq.sort()
print((seq[K - 1]))


s = input()
k = int(input())
n = len(s)

dic = {}
ansl = []

for i in range(n):
    for j in range(i, n):
        length = j-i+1
        if length > k:
            continue
        partial = s[i:j+1]
        if not dic.get(partial, False):
            dic[partial] = True
            ansl.append(partial)

ansl.sort()
print((ansl[k-1]))


import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    s = list(input())
    k = int(input())
    subs = set()
    lens = len(s)
    for i1 in range(k + 1):
        for i2 in range(lens - i1):
            subs.add("".join(s[i2:i2+i1+1]))
    subs_l = list(subs)
    subs_l.sort()
    print(subs_l[k-1])

def __starting_point():
    main()
__starting_point()

s = input()
k = int(input())
l = []
for i in range(len(s)):
    for j in range(i+1,min(i+k+1, len(s)+1)):
        l.append(s[i:j])
print(sorted(list(set(l)))[k-1])

#!/usr/bin/env python3
from collections import deque


def search(moji):
    num = len(moji)
    setsn = set([])
    for i in range(len(s)-num+1):
        if s[i:i+num] == moji:
            str_ = s[i:i+num+1]
            if len(str_) == num+1:
                setsn.add(str_)
    sorted_setsn = sorted(setsn, reverse=True)

    return sorted_setsn


s = str(input())
k = int(input())
n = len(s)

sets1 = set([])
for i in range(0, len(s)):
    sets1.add(s[i])

sorted_sets1 = sorted(sets1)

# if k == 1:
#     print(sorted_sets1[0])
#     return
# else:
#     k -= 1

dq = deque(sorted_sets1)

while(len(dq)):
    # print(dq, k)
    moji = dq.popleft()
    k -= 1
    if k == 0:
        print(moji)
        return
    sorted_setsn = search(moji)

    # print(sorted_setsn)
    dq.extendleft(sorted_setsn)


s = input()

d = ["z"*5010]*5

k = int(input())
for i in range(len(s)):
    for j in range(i, i+k):
        x = s[i:j+1]
        if x in d or x == '':
            continue
        l = 0
        while l < 5 and x > d[l]:
            l += 1
        # print(k, d[0:k], x, d[k:])
        if l < 5:
            d = d[0:l] + [x] + d[l:]
            d = d[0:5]
        # print(f"->{d}")
# l = list(d)
# l.sort()
# print(l)
# if l[0] == '':
    # l = l[1:]

print((d[k-1]))


S = input()
N = len(S)
K = int(input())
S_list = sorted(set(list(S)))

memo = {}

for small_char in S_list:
    for i in range(N):
        if S[i] == small_char:
            for j in range(i+1, i+K+1):
                word = S[i:j]
                memo[word] = None
    if len(memo) >= K:
        break

ans_list = sorted(list(memo.keys()))
print((ans_list[K-1]))


s = input()
K = int(input())

subst = []
for i in range(5):
  for j in range(len(s) - i):
    subst.append(s[j:j+i+1])

subst = list(set(subst))
subst.sort()

print(subst[K - 1])

S = input()
N = len(S)
K = int(input())
ttl = []
for i in range(N):
    for j in range(N - i):
        ttl.append(S[j:j+i+1])
    if i > K:
        break
ttl = sorted(list(set(ttl)))
print(ttl[K-1])

from itertools import combinations
s = input()
n = int(input())

le = len(s)
tmp = s[:5]

for i in range(le - 4):
    tmp = min(tmp, s[i:i+5])

seed = tuple(combinations(list(range(min(6, le+1))), 2))
res = set()
for i, j in seed:
    res.add(tmp[i:j])
ans = sorted(res)
print((ans[n - 1]))


S = input()
K = int(input())

N = len(S)

memo = []
for i in range(N):
    for d in range(1, min(K, N - i) + 1):
        memo.append(S[i:i + d])

print(sorted(set(memo))[K - 1])

s = input()
k = int(input())
se = set()
for i in s:
    se.add(i)
if len(s) > 1:
    for i in range(len(s)-1):
        se.add(s[i]+s[i+1])
if len(s) > 2:
    for i in range(len(s)-2):
        se.add(s[i]+s[i+1]+s[i+2])
if len(s) > 3:
    for i in range(len(s)-3):
        se.add(s[i]+s[i+1]+s[i+2]+s[i+3])
if len(s) > 4:
    for i in range(len(s)-4):
        se.add(s[i]+s[i+1]+s[i+2]+s[i+3]+s[i+4])
se = sorted(se)
print(se[k-1])

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()
    K = int(readline())

    subs = set()

    for i in range(len(S)):
        for j in range(i + 1, min(len(S) + 1, i + K + 1)):
            subs.add(S[i:j])

    subs = sorted(subs)
    print((subs[K - 1]))

    return


def __starting_point():
    main()

__starting_point()

# Kは最大で５なので、1~５文字の部分文字列を全列挙して重複省いてソートすれば終わり
s = input()
K = int(input())

sub = set()
for i in range(K):
    for j in range(len(s) - i):
        sub.add(s[j:j + i + 1])

sub = list(sub)
sub.sort()

print(sub[K - 1])

def main():
    S = input()
    k = int(input())
    setS = set(list(S))
    count = 0
    ans = []
    for j in range(1, k + 1):
        for i in range(len(S) - j + 1):
            ans.append(S[i:i + j])
    ans = sorted(list(set(ans)))
    print((ans[k - 1]))

def __starting_point():
    main()

__starting_point()

s = input()
k = int(input())

subs_list = []
for i in range(len(s)):
    for j in range(i+1, i+k+1):
        subs_list.append(s[i:j])

ans = sorted(set(subs_list))
print((ans[k-1]))


S = list(input())
n = len(S)
k = int(input())
H = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
p = 0
cnt = 0
D = set()

while True:
    for i in range(n):
        if S[i] == H[p]:
            for j in range(1, 6):
                if i + j <= n:
                    D.add("".join(S[i:i + j]))

    p += 1
    if len(list(D)) >= k:
        break

D = list(D)
D.sort()

print(D[k-1])

s = input()
k = int(input())

cand = []
for i in range(len(s)):
    temp = ''
    for j in range(k):
        if i + j >= len(s):continue
        temp += s[i + j]
        cand.append(temp)

cand.sort()
#print(cand)
ans = cand.pop(0)
k -= 1
while k != 0:
    temp = cand.pop(0)
    if temp == ans:continue 
    ans = temp
    k -= 1

print(ans)

S = input()
K = int(input())
print(sorted(set(S[i:i+j+1] for i in range(len(S)) for j in range(K)))[K-1])

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

s = input()
K = INT()


substr = []

for l in range(len(s)):
	r = l+1
	while r < len(s)+1:
		#print(l, r, substr)
		if bisect(substr, s[l:r]) == 5:
			break
		elif s[l:r] in substr:
			r += 1
		elif s[l:r] not in substr:
			insort(substr, s[l:r])
			substr = substr[:5]
			if s[l:r] in substr:
				r += 1


#print(substr)
print((substr[K-1]))


S = input()
K = int(input())

substrings = set()
for length in range(1, K + 1):
    for i in range(len(S) - length + 1):
        substrings.add(S[i:i + length])

substrings = sorted(substrings)

print((substrings[K - 1]))


s = str(input())
K = int(input())
# sがabcac の場合、a,bca,ac などは部分列(substring
# abc とabの場合、abの方が辞書順で小さいと判断する。
# abc とabaの場合、abaの方が小さい

substrings = set([])
for i in range(5):
    for j in range(len(s) - i):
        # print(i, j)
        substrings.add(s[j:j + i + 1])
# print(substrings)
print((sorted(substrings)[K - 1]))


s = input()
k = int(input())
l = "abcdefghijklmnopqrstuvwxyz"
d = {}

for i in range(26):
    cnt = s.count(l[i])
    pre = 0
    if cnt > 0:
        for j in range(cnt):
            pos = s.find(l[i], pre)
            pre = pos + 1
            for m in range(min(len(s) - pos, k)):
                if s[pos:pos + m + 1] not in d:
                    d[s[pos:pos + m + 1]] = 1
    if len(d) >= k:
        dl = []
        for i in d.keys():
            dl.append(i)
        dl.sort()
        print(dl[k - 1])
        return

s = input()
l = len(s)
k = int(input())
A = set()
for i in range(l):
    for j in range(1, 6):
        if i+j <= l:
            A.add(s[i:i+j])
ans = sorted(A)
print(ans[k-1])

def main():
    S = input()
    N = len(S)
    K = int(input())
    top_k = []
    for i in range(N):
        for j in range(i + 1, min([i + K, N]) + 1):
            st = S[i:j]
            top_k.append(st)
            if len(top_k) > K:
                top_k = list(set(top_k))
                top_k.sort()
                top_k = top_k[:K]
    top_k.sort()
    print(top_k[-1])


def __starting_point():
    main()
__starting_point()

s = input()
k = int(input())

alphabets = [chr(i + 97) for i in range(26)]

for char in alphabets:
    l = []
    for i in range(len(s)):
        if s[i] == char:
            l.append(s[i:])

    if l == []:
        continue

    if k == 1:
        print((l[0][0]))
        return
    
    k -= 1

    strings = set([])
    for i in l:
        for j in range(2, min(k+2, len(i)+1)):
            strings.add(i[:j])
    strings = list(strings)
    strings.sort()
    
    if len(strings) >= k:
        print((strings[k-1]))
        return
    else:
        k -= len(strings)


s=input();k=int(input());print(sorted({s[i:i+j]for i in range(len(s))for j in range(1,k+1)})[k-1])

s = input().rstrip()
k = int(input())

n = len(s)
ss = set()
for i in range(n):
    for j in range(1, k + 1):
        ss.add(s[i:i+j])
print(sorted(ss)[k - 1])

s = input()
k = int(input())
c = []
for i in range(len(s)):
    for j in range(k): c.append(s[i:i+j+1])
c.sort()
pre = ''
for x in c:
    if pre == x: continue
    k -= 1
    if k == 0:
        print(x)
        break
    pre = x


# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
K = ir()
cand = set()
length = len(S)
for i in range(length):
    for j in range(1, 6):
        cand.add(S[i:i+j])

answer = sorted(list(cand))[K-1]
print(answer)


# import sys
# sys.setrecursionlimit(10 ** 6)
import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(S, K):
    n = len(S)
    l = [''] + ['あ'] * 5
    for i in range(n):
        for j in range(i, i + 5):
            tmp = S[i:j + 1]
            tmp_num = bisect.bisect_left(l, tmp)
            if tmp_num > 5:
                continue
            elif l[tmp_num] != tmp:
                l.insert(tmp_num, tmp)
                l.pop(-1)
    print((l[K]))


def __starting_point():
    S = input()
    K = int(input())
    solve(S, K)

    # # test
    # from random import randint
    # from func import random_str
    # n = 5000
    # S = random_str(n, 'abcde')
    # K = randint(1, 5)
    # print(S)
    # print(K)
    # solve(S, K)

__starting_point()

s = input()
l = len(s)
k = int(input())
A = set()
for i in range(l):
    for j in range(1, 6):
        if i+j <= l:
            A.add(s[i:i+j])
ANS = sorted(A)
print((ANS[k-1]))


s = input()
k = int(input())
substring = set([])
for i in range(min(len(s), 5)):
    for j in range(0, len(s)-i):
        substring.add(s[j:i+j+1])
ans = list(substring)
ans.sort()
print(ans[k-1])

s=input()
k=int(input())
ans=[]

for i in range(len(s)):
  for j in range(i+1,min(k+i+1,len(s)+1)):
    ans.append(s[i:j])

ans=list(set(ans))
ans.sort()
print((ans[k-1]))


S=input()
K=int(input())
N=len(S)
s=set()
for i in range(N):
    for j in range(i+1,min(i+K+1,N+1)):
        s|={S[i:j]}
A=list(s)
A.sort()
print((A[K-1]))


s = input()
k = int(input())
seen = set()
i = 1

while i<=k:
  for j in range(len(s)):
    seen.add(s[j:j+i])
  i += 1

print(sorted(seen)[k-1])

# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
k=I()
n=len(s)
strs=[]
for i in range(n):
    for j in range(1,k+1):
        strs.append(s[i:i+j])
print(sorted(list(set(strs)))[k-1])

from itertools import*
s = input()
k = int(input())
l = len(s)
print(sorted(set(s[i:j] for i, j in combinations(range(l+1), 2) if j - i <= k))[k-1])

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

def main():
	s = input()
	K = INT()

	strings = set()
	for  i in range(1, K+1): #文字列の長さ : K番目で長さがK以上のを考える必要はない。
		for j in range(len(s)-i+1): #スタート地点
			#print(j, i)
			strings.add(s[j:j+i])

	print((sorted(strings)[K-1]))

def __starting_point():
	main()

__starting_point()

s = input()
k = int(input())

l = k
count = 0
n = len(s)
lst = 'abcdefghijklmnopqrstuvwxyz'
for alpha in lst:
    alpha_index = []
    for index in range(n):
        if alpha == s[index]:
            alpha_index.append(index)
    if len(alpha_index) > 0:
        cand_lst = []
        for index2 in alpha_index:
            end_lst = [index2 + m for m in range(1,6) if index2 + m <= n]
            for end in end_lst:
                cand_lst.append(s[index2:end])
        cand_lst = set(cand_lst)
        cand_lst = sorted(cand_lst)
        #print('alpha:  ', alpha)
        #print('alpha_index: ', alpha_index)
        #print('cand_lst: ', cand_lst)
        if len(cand_lst) < l:
            l = l - len(cand_lst)
        else:
            res = cand_lst[l-1]
            break

print(res)

S = input()
K = int(input())
A = []
for i in range(len(S)):
    for j in range(1,6):
        a = S[i:i+j]
        A.append(a)   
        #print(A)

A = set(A)
A = sorted(set(A))
print(A[K-1])

from collections import defaultdict
import string
s = input()
K = int(input())
location = defaultdict(list)
for i, s_i in enumerate(s):
    location[s_i].append(i)
count = 0
s_list = []
for c in string.ascii_lowercase[:26]:
    if location[c] == []:
        continue
    for idx in location[c]:
        for i in range(K):
            if idx + i + 1 > len(s):
                break
            if s[idx:idx+i+1] in s_list:
                continue
            s_list.append(s[idx:idx+i+1])
    count += 1
    if count == K:
        break
s_list.sort()
print(s_list[K-1])

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    s = list(input())
    k = int(input())
    k -= 1

    d1 = defaultdict(list)
    for i, c in enumerate(s):
        d1[c].append(i)
    d2 = sorted(d1.items())

    lens = len(s)
    for d2e in d2:
        subs = set()
        subs.add(d2e[0])
        for d2ee in d2e[1]:
            end = min(lens + 1, d2ee + k + 2)
            for i1 in range(d2ee+1, end):
                subs.add("".join(s[d2ee:i1]))
        if len(subs) > k:
            subsl = list(subs)
            subsl.sort()
            print(subsl[k])
            return
        else:
            k -= len(subs)

def __starting_point():
    main()
__starting_point()

s = input()
k = int(input())
n = len(s)
temp_set = set()
for i in range(n):
    for j in range(i + 1, min(i + k + 1, n + 1)):
        temp_set.add(s[i:j])
temp_list = sorted(list(temp_set))
print(temp_list[k - 1])

def main():
    s=input()
    k=int(input())
    a=set()
    for l in range(5):
        for i in range(len(s)-l):
            a.add(s[i:i+l+1])
    print(sorted(a)[k-1])

def __starting_point():
    main()
__starting_point()

#!/usr/bin/env python3


def main():
    s = input()
    N = len(s)
    K = int(input())
    X = set()
    for i in range(1,K+1):
        for j in range(N-i+1):
            X.add(s[j:j+i])
    print((sorted(X)[K-1]))

def __starting_point():
    main()

__starting_point()

s = input()
k = int(input())
li = []
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        if j-i<=6:
            li += [s[i:j]]
li2 = set(li)
li3 = sorted(li2)
print(li3[k-1])

s=input()
n=len(s)
k=int(input())
l=[]
for i in range(n):
  for j in range(i,i+k+1):
    a=s[i:j+1]
    l.append(a)
l=set(l)
l=list(l)
l.sort()
print(l[k-1])

S = input()
N = len(S)
K = int(input())
cnt = {i: [] for i in range(N)}
for i in range(N):
    for j in range(N - i):
        s = S[j:j+i+1]
        l = len(s)
        if s not in cnt[l-1]:
            cnt[l-1].append(s)
    if i > K:
        break
ttl = []
for k, v in cnt.items():
    ttl.extend(v)
ttl.sort()
print(ttl[K-1])

s=input()
s=s+'0'
K=int(input())
p=set()
for i in range(len(s)):
  for j in range(1,6):
    if i+j<=len(s)-1:
      p.add(s[i:j+i])
p=sorted(p)
print(p[K-1])

s = input()
k = int(input())
lst = sorted(list(set(s)))
tank = []
for tg in lst:
    for i in range(len(s)):
        if s[i]==tg:
            for j in range(k):
                if i+j<=len(s) and (s[i:i+j+1] not in tank):
                    tank.append(s[i:i+j+1])
    if len(tank) >= k:
        break
tank.sort()
print(tank[k-1])

s = input()
K = int(input())
N = len(s)

ans = []

for i in range(min(K, N)):
  for j in range(N-i):
    ans.append(s[j:j+i+1])
  
ans.sort()
count = 0
now = '0'
for i in range(len(ans)):
  if ans[i] != now:
    count += 1
    now = ans[i]
    if count == K:
      print(now)
      return
    


from collections import deque

s = input()
k = int(input())

def index_Multi(List,liter):
    #Listはリスト本体・literは検索したい文字
    index_L = []
    for val in range(0,len(List)):
        if liter == List[val]:
            index_L.append(val)
    return index_L

def substr(s, k, j):
    n = ord("a")

    while True:
        l = index_Multi(s, chr(n+j))
        word = []
        if len(l) == 0:
            n += 1
        else:
            for p in l:
                for i in range(k):
                    word.append(s[p:p+i+1])
            sword = set(word)
            if len(sword) >= k:
                tword = list(sword)
                tword.sort()
                #print(tword, sword)
                return tword[k-1]
            else:
                return substr(s, k-len(sword), j+1)
            break

print(substr(s, k, 0))

def calc( s , k , n):

	bruh = {}
	for i  in range(1, k + 1): # length
		for j in range( n - ( i - 1)): # start 
			bruh[s[j: j + i:]] = 0
	another = bruh.keys()
	another = sorted(another)
	print( another[k - 1])

s = input()

k = int(input())

n = len(s)
 
calc( s , k , n)

s = input()
k = int(input())

SUBSTRINGS = set()
for i in range(len(s)):
    for j in range(i + 1, i + 6):
        SUBSTRINGS.add(s[i:j])

SUBSTRINGS = sorted(SUBSTRINGS)

print((SUBSTRINGS[k - 1]))