import collections

import math

n = int(eval(input()))

s = [0]*n

T = [0]*n

L = [0]*n

ans = 0

for i in range(n):

	s[i] = eval(input())

	T[i] = sorted(list(s[i]))

	L[i] = ''.join(T[i])

D = collections.Counter(L)

for i in list(D.values()):

	ans += i*(i-1)/2

print((int(ans)))
import collections

n = int(eval(input()))

s = [0]*n

L = [0]*n

ans = 0

for i in range(n):

	s[i] = eval(input())

	L[i] = ''.join(sorted(list(s[i])))

D = collections.Counter(L)

for i in list(D.values()):

	ans += i*(i-1)//2

print(ans)
import collections
import math

n = int(eval(input()))
s = [0] * n
T = [0] * n
L = [0] * n
ans = 0
for i in range(n):
    s[i] = eval(input())
    T[i] = sorted(list(s[i]))
    L[i] = "".join(T[i])
D = collections.Counter(L)
for i in list(D.values()):
    ans += i * (i - 1) / 2
print((int(ans)))

import collections

n = int(eval(input()))
s = [0] * n
L = [0] * n
ans = 0
for i in range(n):
    s[i] = eval(input())
    L[i] = "".join(sorted(list(s[i])))
D = collections.Counter(L)
for i in list(D.values()):
    ans += i * (i - 1) // 2
print(ans)

-import math -T = [0] * n -    T[i] = sorted(list(s[i])) -    L[i] = "".join(T[i]) +    L[i] = "".join(sorted(list(s[i]))) -    ans += i * (i - 1) / 2 -print((int(ans))) +    ans += i * (i - 1) // 2 +print(ans)