11978 - Problem E   

Description

Given a string S, output all different possible set of K characters in the string with P paddings. And sort them in the dictionary order. A padding is expressed as an underline '_'.

For example, if K=2 and P=1, and the given string S is ‘CDBABBD’, the output would be

_AB
_AC
_AD
_BB
_BC
_BD
_CD
_DD
A_B
A_C
A_D
AB_
AC_
AD_
B_B
B_C
B_D
BB_
BC_
BD_
C_D
CD_
D_D
DD_

Input

The first line of input contains a positive integer T (T <= 30), which indicates the number of test cases. For each case, there is a string S, a positive integer K, and a nonnegative integer P in a line. The length of the S is less than or equal to 100 and S contains only 'A'-'K'; The number K, less than or equal to 10, indicates the length of substrings.

For test 1 & 2: T <= 15, K <= 5, P <= 2,  |S| <= 25

T, K, |S| are all positive integers, P is a nonnegative integer, and K <= |S| for all test cases.

Output

For each test case, print all different possible sets of K characters in the string. And sort them in the dictionary order, one substring per line. Print a blank line after each test case.

Sample Input  Download

Sample Output  Download

Tags




Discuss