Similarity
Substitution in the Latin alphabet involves replacing each letter with another unique letter. Two words of the same length are considered similar if a substitution exists that can transform one word into the other. For instance, the words dog and cat, as well as nine and pope, are similar. However, dog and pup, or nine and four, are not similar. If two words are similar to a third word, they are also similar to each other. Therefore, any collection of words can be divided into groups of mutually similar words. The number of these groups is known as the similarity index. For example, the similarity index of the set man, num, kid, mom, dad is 2, because man and kid form one group, while num, mom, and dad form another. Given N words, each of length L, determine the similarity index of this set of words.
Input data. The first line contains the number N, representing the number of words. The following N lines each contain one word. Each word is a sequence of lowercase Latin letters. 0 < N <= 5000. 0 < L <= 50. Output data. Output a single number, which is the similarity index of the given set of words.