#P2882. The k-th String sequence
The k-th String sequence
Problem Description
Given a String s, we will first collect all distinct positive length subsequences of s, and place them in a list L. A subsequence of s is obtained by deleting 0 or more characters. Next, sort L into ascending order by length. Where ties occur, break them lexicographically. Here uppercase letters occur before lowercase letters. Finally, return the String in position k % TOTAL (0-based), where TOTAL is the number of elements in L.
Input
Line 1: The input contains a single integer T , the number of test cases.
Line 2...T+1: s k (The input string s and the position of the output string).
(The length of s is between 2 and 50. Each character in s will be a letter ('A'-'Z','a'-'z').
k will be an integral value between 0 and 2^63 - 1 inclusive. )e.
Output
Line 1...T: Output the string for each test case.
3
ABCD 15
ABCD 14
AbcdAbcdAbcd 39283423984923
A
ABCD
AbAbdbd