Problem:
Score : 300 points

Problem Statement

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

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 N strings s_1, s_2, \ldots, s_N. Each of these strings has a length of 10 and consists of lowercase English characters. Additionally, all of these strings are distinct. Find the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Constraints

2 \leq N \leq 10^5

s_i is a string of length 10.

Each character in s_i is a lowercase English letter.

s_1, s_2, \ldots, s_N are all distinct.

Input

Input is given from Standard Input in the following format:

N
s_1
s_2
:
s_N

Output

Print the number of pairs of integers i, j (1 \leq i < j \leq N) such that s_i is an anagram of s_j.

Sample Input 1

3
acornistnt
peanutbomb
constraint

Sample Output 1

1

s_1 = acornistnt is an anagram of s_3 = constraint. There are no other pairs i, j such that s_i is an anagram of s_j, so the answer is 1.

Sample Input 2

2
oneplustwo
ninemodsix

Sample Output 2

0

If there is no pair i, j such that s_i is an anagram of s_j, print 0.

Sample Input 3

5
abaaaaaaaa
oneplustwo
aaaaaaaaba
twoplusone
aaaabaaaaa

Sample Output 3

4

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

Solution in C (GCC 5.4.1) (judge verdict: Runtime Error)

#include<stdio.h>

int main(void){

  int n;
  int i,j,k,l;
  int ans=0;
  int check=0;
  //配列の書記かは基本的にはfor文を回さないといけないが、全部を０で初期化する場合に限り、
  //この構文で行ける。

  scanf("%d",&n);
  char s[n][10];
  for(i=0;i<n;i++)
  scanf("%s",s[n]);

  for(i=0;i<n;i++){
    int alp1[26]={0};
    int alp2[26]={0};
    for(j=i+1;j<n;j++){
      check=0;
      for(k=0;k<10;k++){
        if(s[i][k]=='a')
        alp1[0]++;
        if(s[j][k]=='a')
        alp2[0]++;

        if(s[i][k]=='b')
        alp1[1]++;
        if(s[j][k]=='b')
        alp2[1]++;

        if(s[i][k]=='c')
        alp1[2]++;
        if(s[j][k]=='c')
        alp2[2]++;

        if(s[i][k]=='d')
        alp1[3]++;
        if(s[j][k]=='d')
        alp2[3]++;

        if(s[i][k]=='e')
        alp1[4]++;
        if(s[j][k]=='e')
        alp2[4]++;

        if(s[i][k]=='f')
        alp1[5]++;
        if(s[j][k]=='f')
        alp2[5]++;

        if(s[i][k]=='g')
        alp1[6]++;
        if(s[j][k]=='g')
        alp2[6]++;

        if(s[i][k]=='h')
        alp1[7]++;
        if(s[j][k]=='h')
        alp2[7]++;

        if(s[i][k]=='i')
        alp1[8]++;
        if(s[j][k]=='i')
        alp2[8]++;

        if(s[i][k]=='j')
        alp1[9]++;
        if(s[j][k]=='j')
        alp2[9];

        if(s[i][k]=='k')
        alp1[10]++;
        if(s[j][k]=='k')
        alp2[10]++;

        if(s[i][k]=='l')
        alp1[11]++;
        if(s[j][k]=='l')
        alp2[11]++;

        if(s[i][k]=='m')
        alp1[12]++;
        if(s[j][k]=='m')
        alp2[12]++;

        if(s[i][k]=='o')
        alp1[13]++;
        if(s[j][k]=='o')
        alp2[13]++;

        if(s[i][k]=='p')
        alp1[14]++;
        if(s[j][k]=='p')
        alp2[14]++;

        if(s[i][k]=='q')
        alp1[15]++;
        if(s[j][k]=='q')
        alp2[15]++;

        if(s[i][k]=='r')
        alp1[16]++;
        if(s[j][k]=='r')
        alp2[16]++;

        if(s[i][k]=='s')
        alp1[17]++;
        if(s[j][k]=='s')
        alp2[17]++;

        if(s[i][k]=='t')
        alp1[18]++;
        if(s[j][k]=='t')
        alp2[18]++;

        if(s[i][k]=='u')
        alp1[19]++;
        if(s[j][k]=='u')
        alp2[19]++;

        if(s[i][k]=='v')
        alp1[20]++;
        if(s[j][k]=='v')
        alp2[20]++;

        if(s[i][k]=='w')
        alp1[21]++;
        if(s[j][k]=='w')
        alp2[21]++;

        if(s[i][k]=='x')
        alp1[22]++;
        if(s[j][k]=='x')
        alp2[22]++;

        if(s[i][k]=='y')
        alp1[23]++;
        if(s[j][k]=='y')
        alp2[23]++;

        if(s[i][k]=='z')
        alp1[24]++;
        if(s[j][k]=='z')
        alp2[24]++;

        if(s[i][k]=='n')
        alp1[25]++;
        if(s[j][k]=='z')
        alp2[25]++;
        }
      for(k=0;k<26;k++){
        if(!(alp1[k]==alp2[k])){
        check=-1;
      break;    }
      }
      if(check!=-1)
      ans++;
    }
  }
printf("%d",ans);

    return 0;
}