100 atcoder#ABC137C. [ABC137C] Green Bin

[ABC137C] Green Bin

Score : 300300 points

Problem Statement

We will call a string obtained by arranging the characters contained in a string aa in some order, an anagram of aa.

For example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.

Given are NN strings s1,s2,,sNs_1, s_2, \ldots, s_N. Each of these strings has a length of 1010 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i,ji, j (1i<jN)(1 \leq i < j \leq N) such that sis_i is an anagram of sjs_j.

Constraints

  • 2N1052 \leq N \leq 10^5
  • sis_i is a string of length 1010.
  • Each character in sis_i is a lowercase English letter.
  • s1,s2,,sNs_1, s_2, \ldots, s_N are all distinct.

Input

Input is given from Standard Input in the following format:

NN

s1s_1

s2s_2

::

sNs_N

Output

Print the number of pairs of integers i,ji, j (1i<jN)(1 \leq i < j \leq N) such that sis_i is an anagram of sjs_j.

3
acornistnt
peanutbomb
constraint
1

s1=s_1 = acornistnt is an anagram of s3=s_3 = constraint. There are no other pairs i,ji, j such that sis_i is an anagram of sjs_j, so the answer is 11.

2
oneplustwo
ninemodsix
0

If there is no pair i,ji, j such that sis_i is an anagram of sjs_j, print 00.

5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa
4

Note that the answer may not fit into a 3232-bit integer type, though we cannot put such a case here.