S = eval(input())

N = len(S)

K = int(eval(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 list(cnt.items()):

    ttl.extend(v)

ttl.sort()

print((ttl[K-1]))
S = eval(input())

N = len(S)

K = int(eval(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]))
S = eval(input())
N = len(S)
K = int(eval(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 list(cnt.items()):
    ttl.extend(v)
ttl.sort()
print((ttl[K - 1]))

S = eval(input())
N = len(S)
K = int(eval(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]))

-cnt = {i: [] for i in range(N)} +ttl = [] -        s = S[j : j + i + 1] -        l = len(s) -        if s not in cnt[l - 1]: -            cnt[l - 1].append(s) +        ttl.append(S[j : j + i + 1]) -ttl = [] -for k, v in list(cnt.items()): -    ttl.extend(v) -ttl.sort() +ttl = sorted(list(set(ttl)))