import math

n = int(eval(input()))

l = ["".join(sorted(eval(input()))) for i in range(n)]

l.sort()

c = 0

b = l[0]

ans = 0

for s in l[1:]:

    if s == b:

        c += 1

    else:

        ans += c * (c + 1) * 0.5

        c = 0

        b = s

ans += c * (c + 1) * 0.5

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

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



dic = {}

for w in s:

    if w in dic:

        dic[w] += 1

    else:

        dic[w] = 1



ans = 0

for w in dic:

    ans += dic[w] * (dic[w] - 1) // 2



print(ans)

import math

n = int(eval(input()))
l = ["".join(sorted(eval(input()))) for i in range(n)]
l.sort()
c = 0
b = l[0]
ans = 0
for s in l[1:]:
    if s == b:
        c += 1
    else:
        ans += c * (c + 1) * 0.5
        c = 0
        b = s
ans += c * (c + 1) * 0.5
print((int(ans)))

n = int(eval(input()))
s = ["".join(sorted(eval(input()))) for _ in range(n)]
dic = {}
for w in s:
    if w in dic:
        dic[w] += 1
    else:
        dic[w] = 1
ans = 0
for w in dic:
    ans += dic[w] * (dic[w] - 1) // 2
print(ans)

-import math - -l = ["".join(sorted(eval(input()))) for i in range(n)] -l.sort() -c = 0 -b = l[0] +s = ["".join(sorted(eval(input()))) for _ in range(n)] +dic = {} +for w in s: +    if w in dic: +        dic[w] += 1 +    else: +        dic[w] = 1 -for s in l[1:]: -    if s == b: -        c += 1 -    else: -        ans += c * (c + 1) * 0.5 -        c = 0 -        b = s -ans += c * (c + 1) * 0.5 -print((int(ans))) +for w in dic: +    ans += dic[w] * (dic[w] - 1) // 2 +print(ans)