n = int(eval(input()))

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

dict = {}

alpha = "abcdefghijklmnopqrstuvwxyz"



for s in arr:

    count = [0]*26

    for i in range(10):

        for j in range(26):

            if s[i] == alpha[j]:

                count[j] += 1

                break

    count = tuple(count)

    if count not in dict:

        dict[count] = 1

    else:

        dict[count] += 1

ans = 0

for val in list(dict.values()):

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

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

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

ans_dict = {}



for s in arr:

    samp = sorted(s)

    tmp = ""

    for i in samp:

        tmp = tmp + i

    if tmp in ans_dict:

        ans_dict[tmp] += 1

    else:

        ans_dict[tmp] = 1



ans = 0

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

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

print(( int(ans) ))

    
n = int(eval(input()))
arr = [eval(input()) for _ in range(n)]
dict = {}
alpha = "abcdefghijklmnopqrstuvwxyz"
for s in arr:
    count = [0] * 26
    for i in range(10):
        for j in range(26):
            if s[i] == alpha[j]:
                count[j] += 1
                break
    count = tuple(count)
    if count not in dict:
        dict[count] = 1
    else:
        dict[count] += 1
ans = 0
for val in list(dict.values()):
    ans += val * (val - 1) / 2
print((int(ans)))

n = int(eval(input()))
arr = [eval(input()) for _ in range(n)]
ans_dict = {}
for s in arr:
    samp = sorted(s)
    tmp = ""
    for i in samp:
        tmp = tmp + i
    if tmp in ans_dict:
        ans_dict[tmp] += 1
    else:
        ans_dict[tmp] = 1
ans = 0
for i in list(ans_dict.values()):
    ans += i * (i - 1) / 2
print((int(ans)))

-dict = {} -alpha = "abcdefghijklmnopqrstuvwxyz" +ans_dict = {} -    count = [0] * 26 -    for i in range(10): -        for j in range(26): -            if s[i] == alpha[j]: -                count[j] += 1 -                break -    count = tuple(count) -    if count not in dict: -        dict[count] = 1 +    samp = sorted(s) +    tmp = "" +    for i in samp: +        tmp = tmp + i +    if tmp in ans_dict: +        ans_dict[tmp] += 1 -        dict[count] += 1 +        ans_dict[tmp] = 1 -for val in list(dict.values()): -    ans += val * (val - 1) / 2 +for i in list(ans_dict.values()): +    ans += i * (i - 1) / 2