n = int(eval(input()))

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



s_dict = dict([])



for i in s:

    key = ''.join(sorted(i))

    s_dict.setdefault(key, 0)

    s_dict[key] += 1



ans = 0

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

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

print(ans)
import collections



n = int(eval(input()))

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

s = collections.Counter(s)



ans = 0

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

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

print(ans)
n = int(eval(input()))
s = [list(eval(input())) for _ in range(n)]
s_dict = dict([])
for i in s:
    key = "".join(sorted(i))
    s_dict.setdefault(key, 0)
    s_dict[key] += 1
ans = 0
for v in list(s_dict.values()):
    ans += v * (v - 1) // 2
print(ans)

import collections

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

+import collections + -s = [list(eval(input())) for _ in range(n)] -s_dict = dict([]) -for i in s: -    key = "".join(sorted(i)) -    s_dict.setdefault(key, 0) -    s_dict[key] += 1 +s = ["".join(sorted(list(eval(input())))) for _ in range(n)] +s = collections.Counter(s) -for v in list(s_dict.values()): +for v in list(s.values()):