#1653 Anagram Free

1 s   128 MB  

Description

A string X is an anagram of string Y if X can be obtained by arranging all characters of Y in some order, without removing any characters and without adding new characters. For example, each of the strings "baba", "abab", "aabb" and "abba" is an anagram of "aabb", and strings "aaab", "aab" and "aabc" are not anagrams of "aabb". 
A set of strings is anagram-free if it contains no pair of strings which are anagrams of each other. Given a set of strings S, return the size of its largest anagram-free subset. Note that the entire set is considered a subset of itself.

Input

맨 처음 테스트 케이스의 갯수 T가 주어진다. ( 1 <= T <= 10 )
그 다음 T의 string의 갯수 N( 1 <= N <= 50 )이 주어지고 N의 수만큼 string X가 주어진다.

Output

각 테스트 케이스마다 정답을 출력한다.

Sample Input

Sample Output

2
4
abcd
abdc
dabc
bacd
4
abcd
abac
aabc
bacd
1
2