n = int(eval(input()))



d = dict()



for i in range(n):

  s = "".join(sorted(list(eval(input()))))

  d[s] = d.get(s, 0) + 1



count = 0



for i in list(d.items()):

  count += (i[1] * (i[1] - 1)) // 2



print(count)
import math



n = int(eval(input()))

d = dict()



for _ in range(n):

    s = "".join(sorted([x for x in eval(input())]))

    d[s] = d.get(s, 0) + 1



ans = 0



for v in list(d.values()):

    if v >= 2:

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



print(ans)
n = int(eval(input()))
d = dict()
for i in range(n):
    s = "".join(sorted(list(eval(input()))))
    d[s] = d.get(s, 0) + 1
count = 0
for i in list(d.items()):
    count += (i[1] * (i[1] - 1)) // 2
print(count)

import math

n = int(eval(input()))
d = dict()
for _ in range(n):
    s = "".join(sorted([x for x in eval(input())]))
    d[s] = d.get(s, 0) + 1
ans = 0
for v in list(d.values()):
    if v >= 2:
        ans += (v * (v - 1)) // 2
print(ans)

+import math + -for i in range(n): -    s = "".join(sorted(list(eval(input())))) +for _ in range(n): +    s = "".join(sorted([x for x in eval(input())])) -count = 0 -for i in list(d.items()): -    count += (i[1] * (i[1] - 1)) // 2 -print(count) +ans = 0 +for v in list(d.values()): +    if v >= 2: +        ans += (v * (v - 1)) // 2 +print(ans)