import math

N = int(eval(input()))

sorted_map = {}



def combinations_count(n, r):

    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))



for i in range(N):

    inserted_flag = True

    input_sorted = ''.join(sorted(eval(input())))

    if input_sorted in list(sorted_map.keys()):

        sorted_map[input_sorted] += 1

        inserted_flag = False

    if inserted_flag:

        sorted_map[input_sorted] = 1



count = 0

for count_num in list(sorted_map.values()):

    if count_num == 1:

        continue

    count += combinations_count(count_num, 2)

print(count)
N = int(eval(input()))

Sn = [ ''.join(sorted(eval(input()))) for _ in range(N)]

Sn_key = {}

for s in Sn:

    if s not in Sn_key:

        Sn_key[s] = 1

    else:

        Sn_key[s] += 1

cnt = 0



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

    if v >= 2:

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

print(cnt)
import math

N = int(eval(input()))
sorted_map = {}


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(N):
    inserted_flag = True
    input_sorted = "".join(sorted(eval(input())))
    if input_sorted in list(sorted_map.keys()):
        sorted_map[input_sorted] += 1
        inserted_flag = False
    if inserted_flag:
        sorted_map[input_sorted] = 1
count = 0
for count_num in list(sorted_map.values()):
    if count_num == 1:
        continue
    count += combinations_count(count_num, 2)
print(count)

N = int(eval(input()))
Sn = ["".join(sorted(eval(input()))) for _ in range(N)]
Sn_key = {}
for s in Sn:
    if s not in Sn_key:
        Sn_key[s] = 1
    else:
        Sn_key[s] += 1
cnt = 0
for v in list(Sn_key.values()):
    if v >= 2:
        cnt += v * (v - 1) // 2
print(cnt)

-import math - -sorted_map = {} - - -def combinations_count(n, r): -    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) - - -for i in range(N): -    inserted_flag = True -    input_sorted = "".join(sorted(eval(input()))) -    if input_sorted in list(sorted_map.keys()): -        sorted_map[input_sorted] += 1 -        inserted_flag = False -    if inserted_flag: -        sorted_map[input_sorted] = 1 -count = 0 -for count_num in list(sorted_map.values()): -    if count_num == 1: -        continue -    count += combinations_count(count_num, 2) -print(count) +Sn = ["".join(sorted(eval(input()))) for _ in range(N)] +Sn_key = {} +for s in Sn: +    if s not in Sn_key: +        Sn_key[s] = 1 +    else: +        Sn_key[s] += 1 +cnt = 0 +for v in list(Sn_key.values()): +    if v >= 2: +        cnt += v * (v - 1) // 2 +print(cnt)