9388 - All combinations   

Description

Given N different hexadecimal digits. You have to choose M from them to create all possible numbers in ascending order. For example, given 3 digits "1", "5", "D", and M = 2, the possible answers are "15", "1D", "51", "5D", "D1", "D5".

Input

The first line contains a positive integer T (T <= 100), which indicates how many cases in the input. Each case starts with two positive integers N and M (1 <= M <= N <= 16), which denote the amount of the digits and the amount of digits of desired numbers. The next line contains exactly n different digits(0~F) separated by blanks.

Case 1: 1 <= M <= N <= 10, digit range (0~9), T <= 10
Case 2: 1 <= M <= N <= 10, digit range (0~F), T <= 10
Case 3: 1 <= M <= N <= 10, digit range (0~F), T <= 20
Case 4: 1 <= M <= 10, 1 <= N <= 16, digit range (0~F), T <= 20

Output

For each case, first line outputs the case number. Then, output all the possible numbers in ascending order. (See the Sample Output)

Sample Input  Download

Sample Output  Download

Tags




Discuss