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: Wrong Answer)

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
	int a[100010], b[100010], c[100010], d[100010], e[100010], f[100010], g[100010], h[100010], i[100010], j[100010], k[100010], l[100010], m[100010], n[100010], o[100010], p[100010], q[100010], r[100010], s[100010], t[100010], u[100010], v[100010], w[100010], x[100010], y[100010], z[100010];
	int ii, N, jj, count = 0;
	char str[20];

	scanf("%d\n", &N);
	for (ii = 0; ii < N; ii++) {
		a[ii] = 0;
		b[ii] = 0;
		c[ii] = 0;
		d[ii] = 0;
		e[ii] = 0;
		f[ii] = 0;
		g[ii] = 0;
		h[ii] = 0;
		i[ii] = 0;
		j[ii] = 0;
		k[ii] = 0;
		l[ii] = 0;
		m[ii] = 0;
		n[ii] = 0;
		o[ii] = 0;
		p[ii] = 0;
		q[ii] = 0;
		r[ii] = 0;
		s[ii] = 0;
		t[ii] = 0;
		u[ii] = 0;
		v[ii] = 0;
		w[ii] = 0;
		x[ii] = 0;
		y[ii] = 0;
		z[ii] = 0;
		for (jj = 0; ; jj++) {
			scanf("%c", &str[jj]);
			switch (str[jj]) {
			case 'a':a[ii]++; break;
			case 'b':b[ii]++; break;
			case 'c':c[ii]++; break;
			case 'd':d[ii]++; break;
			case 'e':e[ii]++; break;
			case 'f':f[ii]++; break;
			case 'g':g[ii]++; break;
			case 'h':h[ii]++; break;
			case 'i':i[ii]++; break;
			case 'j':j[ii]++; break;
			case 'k':k[ii]++; break;
			case 'l':l[ii]++; break;
			case 'm':m[ii]++; break;
			case 'n':n[ii]++; break;
			case 'o':o[ii]++; break;
			case 'p':p[ii]++; break;
			case 'q':q[ii]++; break;
			case 'r':r[ii]++; break;
			case 's':s[ii]++; break;
			case 't':t[ii]++; break;
			case 'u':u[ii]++; break;
			case 'v':v[ii]++; break;
			case 'w':w[ii]++; break;
			case 'x':x[ii]++; break;
			case 'y':y[ii]++; break;
			case 'z':z[ii]++; break;
			}
			if (str[jj] == '\n') {
				break;
			}
		}

		if (a[ii] == a[ii + 1] && b[ii] == b[ii + 1] && c[ii] == c[ii + 1] && d[ii] == d[ii + 1] && e[ii] == e[ii + 1] && f[ii] == f[ii + 1]) {
			if (g[ii] == g[ii + 1] && h[ii] == h[ii + 1] && i[ii] == i[ii + 1] && j[ii] == j[ii + 1] && k[ii] == k[ii + 1] && l[ii] == l[ii + 1] && m[ii] == m[ii + 1]) {
				if (n[ii] == n[ii + 1] && o[ii] == o[ii + 1] && p[ii] == p[ii + 1] && q[ii] == q[ii + 1] && r[ii] == r[ii + 1] && s[ii] == s[ii + 1] && t[ii] == t[ii + 1] && u[ii] == u[ii + 1]) {
					if (v[ii] == v[ii + 1] && w[ii] == w[ii + 1] && x[ii] == x[ii + 1] && y[ii] == y[ii + 1] && z[ii] == z[ii + 1]) {
						count++;
					}
				}
			}
		}
	}
	printf("%d", count);
	return 0;
}