11272 - K Characters   

Description

Given a string S, find all different possible set of K characters in the string, and output them in dictionary order. Representation of each set in the ouput should be in alphabetical order.

For example, in the case that K=2 and the given string S is "CDBABBD", the output will be

AB
AC
AD
BB
BC
BD
CD
DD

 

Notice that the set {'D', 'B'} is equivalent to {'B', 'D'}.  

The string "BD" in output stands for the set {'D', 'B'} or {'B', 'D'} equivalently.

Input

The first line of input is a positive integer T (T <= 30), which indicates the number of test cases.

For each test case, there are a non-empty string S and a positive integer K seperated by a space in a line. The length of S is less than or equal to 100 and S contains only upper-case letter 'A'-'K'; The number K is less than or equal to min{10, |S|}.

For dataset 1: T≤10, K≤3, |S|≤10
For dataset 2: T≤15, K≤5, |S|≤25
For dataset 3: T≤20, K≤8, |S|≤50
For dataset 4: T≤30, K≤10, |S|≤100

Output

For each test case, find all different possible set of K characters in the string, and output them in dictionary order. Output one set per line, and the representation of each set should be in alphabetical order.

Print a blank line after each test case.

Sample Input  Download

Sample Output  Download

Tags




Discuss