#C4344. Unique Identification Codes
Unique Identification Codes
Unique Identification Codes
In this problem, you are given several test cases. Each test case consists of a number of "identification codes". Two codes are considered identical if one can be rearranged to form the other. Formally, for any code s, let (f(s)) be the string obtained by sorting the characters of s in non-decreasing order. Two codes (s_1) and (s_2) are considered the same if (f(s_1)=f(s_2)). Your task is to determine the number of unique identification codes for each test case.
Input Example:
For a test case with 5 codes:
5 abc bac xyz zyx foo
After processing, since "abc" and "bac" are equivalent, and "xyz" and "zyx" are equivalent, the number of unique identification codes is 3.
Note: The input and output are provided via standard input (stdin) and standard output (stdout), respectively.
inputFormat
The first line contains an integer (T) representing the number of test cases. For each test case, the first line contains an integer (N) denoting the number of codes. This is followed by (N) lines, each containing a string representing an identification code.
Input Format Summary:
T N code_1 code_2 ... code_N [repeat for each test case]
outputFormat
For each test case, output a single line containing the number of unique identification codes. Codes are compared based on their sorted order as described.
Output Format Summary:
result_1 result_2 ... result_T## sample
2
5
abc
bac
xyz
zyx
foo
4
hello
world
dlorw
foo
3
3
</p>