import math

import collections

n=int(eval(input()))

s=[sorted(eval(input())) for _ in range(n)]

c=[str(collections.Counter(s[i])) for i in range(n)]

k=list(collections.Counter(c).values())

ans = 0

for i in k:

	if i >= 2:

		ans += math.factorial(i)//2//math.factorial(i-2)

print(ans)
n=int(eval(input()))

s=["".join(sorted(eval(input()))) for _ in range(n)]

d={}

ans = 0

for i in s:

	k = d.get(i, 0)

	ans += k

	if k == 0:

		d[i] = 1

	else:

		d[i] += 1

print(ans)
import math
import collections

n = int(eval(input()))
s = [sorted(eval(input())) for _ in range(n)]
c = [str(collections.Counter(s[i])) for i in range(n)]
k = list(collections.Counter(c).values())
ans = 0
for i in k:
    if i >= 2:
        ans += math.factorial(i) // 2 // math.factorial(i - 2)
print(ans)

n = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(n)]
d = {}
ans = 0
for i in s:
    k = d.get(i, 0)
    ans += k
    if k == 0:
        d[i] = 1
    else:
        d[i] += 1
print(ans)

-import math -import collections - -s = [sorted(eval(input())) for _ in range(n)] -c = [str(collections.Counter(s[i])) for i in range(n)] -k = list(collections.Counter(c).values()) +s = ["".join(sorted(eval(input()))) for _ in range(n)] +d = {} -for i in k: -    if i >= 2: -        ans += math.factorial(i) // 2 // math.factorial(i - 2) +for i in s: +    k = d.get(i, 0) +    ans += k +    if k == 0: +        d[i] = 1 +    else: +        d[i] += 1