400780: GYM100247 B Similar Strings
Memory Limit:256 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
B. Similar Stringstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output
Let's call two strings similar if there exists a bijective mapping over characters, which, when applied to the characters of the first string, makes it equal to the second string. For example, «abacaba» and «tetatet» are similar strings, but «test» and «bear» — are not. Given the set of strings, find the number of pairs of similar strings.
InputThe first line contains one integer n — the number of strings.
Next n lines contain non-empty strings of lowercase Latin letters. The sum of lengths of these strings does not exceed 106.
OutputOutput the only integer —the number of pairs of similar strings.
ExamplesInput4Output
abacaba
tetatet
test
bear
1Input
4Output
jury
code
will
pass
2Input
4Output
your
code
wont
pass
3