s=eval(input());k=int(eval(input()));q=[]

for i in range(len(s)):

 for j in range(k):x=s[i:i+j+1];q=q if x in q else sorted(q+[x])[:k]

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

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

-q = [] -for i in range(len(s)): -    for j in range(k): -        x = s[i : i + j + 1] -        q = q if x in q else sorted(q + [x])[:k] -print((q[-1])) +print((sorted({s[i : i + j + 1] for i in range(len(s)) for j in range(k)})[k - 1]))