n = int(eval(input()))

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

sorted_s = sorted(s)



num = 0

num_same = 1

prev = sorted_s[0]

for i in range(1, len(sorted_s)):

    if prev != sorted_s[i]:

        num += int(num_same * (num_same - 1) / 2)

        num_same = 1

        prev = sorted_s[i]

    else:

        num_same += 1

num += int(num_same * (num_same - 1) / 2)

print(num)

n = int(eval(input()))

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

s.sort()





def num_cmb(a, b):

    enum = 1

    denom = 1

    for i in range(b):

        enum *= (a - i)

        denom *= (b - i)

    return enum // denom





sum = 0

count = 1

prev = s[0]

for s_i in s[1::]:

    if prev == s_i:

        count += 1

    else:

        sum += num_cmb(count, 2)

        count = 1

        prev = s_i

if 0 < count:

    sum += num_cmb(count, 2)

print(sum)

n = int(eval(input()))
s = [sorted(eval(input())) for _ in range(n)]
sorted_s = sorted(s)
num = 0
num_same = 1
prev = sorted_s[0]
for i in range(1, len(sorted_s)):
    if prev != sorted_s[i]:
        num += int(num_same * (num_same - 1) / 2)
        num_same = 1
        prev = sorted_s[i]
    else:
        num_same += 1
num += int(num_same * (num_same - 1) / 2)
print(num)

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


def num_cmb(a, b):
    enum = 1
    denom = 1
    for i in range(b):
        enum *= a - i
        denom *= b - i
    return enum // denom


sum = 0
count = 1
prev = s[0]
for s_i in s[1::]:
    if prev == s_i:
        count += 1
    else:
        sum += num_cmb(count, 2)
        count = 1
        prev = s_i
if 0 < count:
    sum += num_cmb(count, 2)
print(sum)

-s = [sorted(eval(input())) for _ in range(n)] -sorted_s = sorted(s) -num = 0 -num_same = 1 -prev = sorted_s[0] -for i in range(1, len(sorted_s)): -    if prev != sorted_s[i]: -        num += int(num_same * (num_same - 1) / 2) -        num_same = 1 -        prev = sorted_s[i] +s = ["".join(sorted(list(eval(input())))) for _ in range(n)] +s.sort() + + +def num_cmb(a, b): +    enum = 1 +    denom = 1 +    for i in range(b): +        enum *= a - i +        denom *= b - i +    return enum // denom + + +sum = 0 +count = 1 +prev = s[0] +for s_i in s[1::]: +    if prev == s_i: +        count += 1 -        num_same += 1 -num += int(num_same * (num_same - 1) / 2) -print(num) +        sum += num_cmb(count, 2) +        count = 1 +        prev = s_i +if 0 < count: +    sum += num_cmb(count, 2) +print(sum)