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 = ["".join(sorted(eval(input()))) for i in range(n)]





from collections import Counter

L = Counter(L)



def num(n):

    return n*(n-1)//2

    

cnt = 0  

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

    cnt +=num(v)

print(cnt)
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 = ["".join(sorted(eval(input()))) for i in range(n)]
from collections import Counter

L = Counter(L)


def num(n):
    return n * (n - 1) // 2


cnt = 0
for v in list(L.values()):
    cnt += num(v)
print(cnt)

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