n = int(eval(input()))

L = []

for i in range(n):

    s= ""

    l = sorted(list(eval(input())))

    for j in range(len(l)):

        s += l[j]

    L.append(s)



dic = {}

for i in range(n):

    if L[i] not in dic:

        dic[L[i]] = 1

    else:

        dic[L[i]] += 1



ans = 0

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

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

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

from collections import Counter

cnt= 0

L = []

for i in range(n):

    s = sorted(eval(input()))

    L.append(("".join(s)))



L = Counter(L)

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

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

print(cnt)
n = int(eval(input()))
L = []
for i in range(n):
    s = ""
    l = sorted(list(eval(input())))
    for j in range(len(l)):
        s += l[j]
    L.append(s)
dic = {}
for i in range(n):
    if L[i] not in dic:
        dic[L[i]] = 1
    else:
        dic[L[i]] += 1
ans = 0
for v in list(dic.values()):
    ans += v * (v - 1) // 2
print(ans)

n = int(eval(input()))
from collections import Counter

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

+from collections import Counter + +cnt = 0 -    s = "" -    l = sorted(list(eval(input()))) -    for j in range(len(l)): -        s += l[j] -    L.append(s) -dic = {} -for i in range(n): -    if L[i] not in dic: -        dic[L[i]] = 1 -    else: -        dic[L[i]] += 1 -ans = 0 -for v in list(dic.values()): -    ans += v * (v - 1) // 2 -print(ans) +    s = sorted(eval(input())) +    L.append(("".join(s))) +L = Counter(L) +for v in list(L.values()): +    cnt += (v - 1) * v // 2 +print(cnt)