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.

Input

The 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.

Output

Output the only integer —the number of pairs of similar strings.

ExamplesInput
4
abacaba
tetatet
test
bear
Output
1
Input
4
jury
code
will
pass
Output
2
Input
4
your
code
wont
pass
Output
3

加入题单

算法标签: