N = int(eval(input()))

s = [''.join(sorted(eval(input()))) for _ in range(N)]



d = {}

for i in s:

  if i not in d:

    d[i] = 1

  else:

    d[i] += 1



ans = 0

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

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

print(ans)
from collections import Counter

n = int(eval(input()))

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



count = Counter(s)

ans = 0

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

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

print(ans)
N = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(N)]
d = {}
for i in s:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1
ans = 0
for i in list(d.values()):
    ans += i * (i - 1) // 2
print(ans)

from collections import Counter

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

-N = int(eval(input())) -s = ["".join(sorted(eval(input()))) for _ in range(N)] -d = {} -for i in s: -    if i not in d: -        d[i] = 1 -    else: -        d[i] += 1 +from collections import Counter + +n = int(eval(input())) +s = ["".join(sorted(list(eval(input())))) for _ in range(n)] +count = Counter(s) -for i in list(d.values()): +for i in list(count.values()):