#ARC097A. [ABC097C] K-th Substring

[ABC097C] K-th Substring

Score : 300300 points

Problem Statement

You are given a string ss. Among the different substrings of ss, print the KK-th lexicographically smallest one.

A substring of ss is a string obtained by taking out a non-empty contiguous part in ss. For example, if ss == ababc, a, bab and ababc are substrings of ss, while ac, z and an empty string are not. Also, we say that substrings are different when they are different as strings.

Let X=x1x2...xnX = x_{1}x_{2}...x_{n} and Y=y1y2...ymY = y_{1}y_{2}...y_{m} be two distinct strings. XX is lexicographically larger than YY if and only if YY is a prefix of XX or xj>yjx_{j} > y_{j} where jj is the smallest integer such that xjyjx_{j} \neq y_{j}.

Constraints

  • 11 \leq s|s| \leq 50005000
  • ss consists of lowercase English letters.
  • 11 \leq KK \leq 55
  • ss has at least KK different substrings.

Partial Score

  • 200200 points will be awarded as a partial score for passing the test set satisfying s|s| \leq 5050.

Input

Input is given from Standard Input in the following format:

ss

KK

Output

Print the KK-th lexicographically smallest substring of KK.

aba
4
b

ss 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.

atcoderandatcodeer
5
andat
z
1
z