Both the problems are task based problems, that means, you will recieve points for every task you complete, although you will recieve points for the task only if all the previous tasks are complete. Read the I/O format below for details.
TASK #1
Nashpati and Jaanpati participated in Codeswap previous year, and they found that, if they memorised the password of one place and entered that in other place, they could view both the questions of the contest in both places. Unfortunately, they gave the feedback that the password should be strong enough, as they also cheated in this way. So this time we could create a strong password. Nashpati thought that the password is complex enough to be memorised enough, if it meets all of the following conditions:
1. The length of password is atleast 10 characters.
2. The password contains at least one lowercase latin letter(i.e. 'a' to 'z' ).
3. The password contains at least one uppercase latin letter(i.e. 'A' to 'Z' ).
4. The password contains atleast one digit.
5. The password contains atleast 1 special character. The special characters are "!", "?", ".", ",", "_"( without quotes).
Given a string of length N, you have to check if the password is complex or not
In a single line, print "YES" if the password is complex, and "NO" otherwise (without quotes).
TASK #2
Now that Jaanpati didn't like the password (doesn't matter if the password is complex or not), she grouped the password elements into following groups:-
1. Lowercase latin letters
2. Uppercase latin letters
3. Digits
4. Special characters mentioned above.
Now she gave priority to each group, where group X has more priority than group Y if first occurrence of X in password is before first occurrence of Y in password.
Now keeping order of each group same, Jaanpati decided that each group gets clubbed i.e. all elements of a group get together (consecutive places), and in such a way that the greater priority group occours before a lower priority group.
You have to print the password in a single line for this task.
TASK #3
Now the problem was that Nashpati didn't like the password. So Nashpati and Jaanpati argued on the password that their final password would be the password same as the TASK #2 but instead of keeping the but instead of keeping the order of each group same, you have to reverse the order of each group.
You have to print the password in a single line for this task.
Input Format:
First line contains the number of test cases (T) and the number of tasks to be answered (K).
First line of each test contains an integer N, the length of the string.
Second line of each test contains a string of length N.
NOTE: Input contains of a character string with characters only belonging to the 4 groups.
Output Format:
For each test case, you have to output the answers of first K tasks, each in new line.
Constraints:
1 <= T <= 10
1 <= N <= 106
1 <= K <= 3
Subpoints:
Subpoint #1 (50% of total): 1 <= N <= 105
Subpoint #2 (50% of total): Original Constraints
In 1st test case, since the string doesn't contain special character, so it isn't complex.
In the 2nd test case, the groups are:- "abcdedg", "A", "0" and "!".