N = int(eval(input()))

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

 

import collections

sortedList = [''.join(sorted(x)) for x in s]

countNum = list(collections.Counter(sortedList).values())

 

import sys

sys.setrecursionlimit(100000000)

 

nCr = {}

def cmb(n, r):

    if r == 0 or r == n: return 1

    if r == 1: return n

    if (n,r) in nCr: return nCr[(n,r)]

    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)

    return nCr[(n,r)]

  

count = 0

memo = [0]*10**6

for n in countNum:

    if n!=1:

        if memo[n] == 0:

            memo[n] = cmb(n, 2)

        count += memo[n]

        

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



S = [""]*N



for i in range(N):

    S[i] = eval(input())

    

def cmb(n, r):

    if n - r < r: r = n - r

    if r == 0: return 1

    if r == 1: return n



    numerator = [n - r + k + 1 for k in range(r)]

    denominator = [k + 1 for k in range(r)]



    for p in range(2,r+1):

        pivot = denominator[p - 1]

        if pivot > 1:

            offset = (n - r) % p

            for k in range(p-1,r,p):

                numerator[k - offset] /= pivot

                denominator[k] /= pivot



    result = 1

    for k in range(r):

        if numerator[k] > 1:

            result *= int(numerator[k])



    return result

  

  

S_set = ["".join(sorted(s)) for s in S]





import collections

import itertools



same_list = collections.Counter(S_set)



ans = [0]*len(same_list)



for i,v in enumerate(same_list.values()):

    if i==0:

        if v==1:

            ans[i] = 0

        else:

            ans[i] = cmb(v, 2)

    else:

        if v==1:

            ans[i] = ans[i-1] + 0

        else:

            ans[i] = ans[i-1] + cmb(v, 2)



print((ans[-1]))
N = int(eval(input()))
s = [eval(input()) for _ in range(N)]
import collections

sortedList = ["".join(sorted(x)) for x in s]
countNum = list(collections.Counter(sortedList).values())
import sys

sys.setrecursionlimit(100000000)
nCr = {}


def cmb(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]


count = 0
memo = [0] * 10**6
for n in countNum:
    if n != 1:
        if memo[n] == 0:
            memo[n] = cmb(n, 2)
        count += memo[n]
print(count)

N = int(eval(input()))
S = [""] * N
for i in range(N):
    S[i] = eval(input())


def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result


S_set = ["".join(sorted(s)) for s in S]
import collections
import itertools

same_list = collections.Counter(S_set)
ans = [0] * len(same_list)
for i, v in enumerate(same_list.values()):
    if i == 0:
        if v == 1:
            ans[i] = 0
        else:
            ans[i] = cmb(v, 2)
    else:
        if v == 1:
            ans[i] = ans[i - 1] + 0
        else:
            ans[i] = ans[i - 1] + cmb(v, 2)
print((ans[-1]))

-s = [eval(input()) for _ in range(N)] -import collections - -sortedList = ["".join(sorted(x)) for x in s] -countNum = list(collections.Counter(sortedList).values()) -import sys - -sys.setrecursionlimit(100000000) -nCr = {} +S = [""] * N +for i in range(N): +    S[i] = eval(input()) -    if r == 0 or r == n: +    if n - r < r: +        r = n - r +    if r == 0: -    if (n, r) in nCr: -        return nCr[(n, r)] -    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1) -    return nCr[(n, r)] +    numerator = [n - r + k + 1 for k in range(r)] +    denominator = [k + 1 for k in range(r)] +    for p in range(2, r + 1): +        pivot = denominator[p - 1] +        if pivot > 1: +            offset = (n - r) % p +            for k in range(p - 1, r, p): +                numerator[k - offset] /= pivot +                denominator[k] /= pivot +    result = 1 +    for k in range(r): +        if numerator[k] > 1: +            result *= int(numerator[k]) +    return result -count = 0 -memo = [0] * 10**6 -for n in countNum: -    if n != 1: -        if memo[n] == 0: -            memo[n] = cmb(n, 2) -        count += memo[n] -print(count) +S_set = ["".join(sorted(s)) for s in S] +import collections +import itertools + +same_list = collections.Counter(S_set) +ans = [0] * len(same_list) +for i, v in enumerate(same_list.values()): +    if i == 0: +        if v == 1: +            ans[i] = 0 +        else: +            ans[i] = cmb(v, 2) +    else: +        if v == 1: +            ans[i] = ans[i - 1] + 0 +        else: +            ans[i] = ans[i - 1] + cmb(v, 2) +print((ans[-1]))