- Time limit: 1.00 s
- Memory limit: 512 MB
You are given a string of length . If all of its substrings (not necessarily distinct) are ordered lexicographically, what is the th smallest of them?
Input
The first input line has a string of length that consists of characters a–z.
The second input line has an integer .
Output
Print the th smallest substring in lexicographical order.
Constraints
Example
Input:
baabaa 10
Output:
ab
Explanation: The 10 smallest substrings in order are a, a, a, a, aa, aa, aab, aaba, aabaa, and ab.