Permutation EX (Hard Version)
Given N digits, we can write them down one by one (in some order) to form a number, say X.
For example, given 1 0 2 3 1, we can form a number 11032.
What are the all possible X such that X can be divided by a positive integer M?
Note that X cannot start with 0. That is, 00123 is not a valid number.
First line contains a number T, indicating that there are T questions follow.
Each question consists of 2 lines. In the first line, there are two positive number N and M, described in Problem Description. In the second line, there are N digits (0~9), each of them seperated by a space.
It is guaranteed that
For each question, print out all number formed by those N digits such that it can be divided by M, in ascending order.
Print out an empty line at the end of each question.
For more information, please refer to Sample Input & Sample Output.