#P1622E. Math Test
Math Test
Description
Petya is a math teacher. of his students has written a test consisting of questions. For each student, it is known which questions he has answered correctly and which he has not.
If the student answers the -th question correctly, he gets points (otherwise, he gets points). Moreover, the points for the questions are distributed in such a way that the array is a permutation of numbers from to .
For the -th student, Petya knows that he expects to get points for the test. Petya wonders how unexpected the results could be. Petya believes that the surprise value of the results for students is equal to , where is the number of points that the -th student has got for the test.
Your task is to help Petya find such a permutation for which the surprise value of the results is maximum possible. If there are multiple answers, print any of them.
The first line contains a single integer () — the number of test cases.
The first line of each test case contains two integers and (; ) — the number of students and the number of questions, respectively.
The second line contains integers (), where is the number of points that the -th student expects to get.
This is followed by lines, the -th line contains the string (), where is if the -th student has answered the -th question correctly, and otherwise.
The sum of for all test cases does not exceed .
For each test case, print integers — a permutation for which the surprise value of the results is maximum possible. If there are multiple answers, print any of them.
Input
The first line contains a single integer () — the number of test cases.
The first line of each test case contains two integers and (; ) — the number of students and the number of questions, respectively.
The second line contains integers (), where is the number of points that the -th student expects to get.
This is followed by lines, the -th line contains the string (), where is if the -th student has answered the -th question correctly, and otherwise.
The sum of for all test cases does not exceed .
Output
For each test case, print integers — a permutation for which the surprise value of the results is maximum possible. If there are multiple answers, print any of them.