s = str(eval(input()))

n = int(eval(input()))



cand = [str(s[0])]

for i in range(len(s)):

    if len(cand) == n and s[i] > cand[-1]:

        continue

    for j in range(i, len(s)):

        tmp = s[i:j+1]

        #print(i,j, tmp, cand)

        if len(cand) == n and tmp > cand[-1]:

            break

        if tmp in cand:

            continue

        cand += [tmp]

        #cand = sorted(cand)

        cand.sort()

        if len(cand) > n:

            cand.pop()





print((cand.pop()))

s = eval(input())

k = int(eval(input()))



substr = []

for n in range(1, k+1):

    for i in range(len(s)-n+1):

        substr.append(s[i:i+n])



substr = list(set(substr))

substr.sort()

print((substr[k-1]))

s = str(eval(input()))
n = int(eval(input()))
cand = [str(s[0])]
for i in range(len(s)):
    if len(cand) == n and s[i] > cand[-1]:
        continue
    for j in range(i, len(s)):
        tmp = s[i : j + 1]
        # print(i,j, tmp, cand)
        if len(cand) == n and tmp > cand[-1]:
            break
        if tmp in cand:
            continue
        cand += [tmp]
        # cand = sorted(cand)
        cand.sort()
        if len(cand) > n:
            cand.pop()
print((cand.pop()))

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

-s = str(eval(input())) -n = int(eval(input())) -cand = [str(s[0])] -for i in range(len(s)): -    if len(cand) == n and s[i] > cand[-1]: -        continue -    for j in range(i, len(s)): -        tmp = s[i : j + 1] -        # print(i,j, tmp, cand) -        if len(cand) == n and tmp > cand[-1]: -            break -        if tmp in cand: -            continue -        cand += [tmp] -        # cand = sorted(cand) -        cand.sort() -        if len(cand) > n: -            cand.pop() -print((cand.pop())) +s = eval(input()) +k = int(eval(input())) +substr = [] +for n in range(1, k + 1): +    for i in range(len(s) - n + 1): +        substr.append(s[i : i + n]) +substr = list(set(substr)) +substr.sort() +print((substr[k - 1]))