import math

n = int(eval(input()))

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

list_mo = []

for i, s in enumerate(list_voc):

    list_n = list(s)

    list_n.sort()

    list_n = ''.join(list_n)

    list_mo.append(list_n)



ans = {}

for s in list_mo:

    if s in ans:

        ans[s] += 1

    else:

        ans[s] = 1





ans_val = []



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





for s in ans:

    if ans[s] != 1:

        ans_val.append(cmb(ans[s], 2))





print((sum(ans_val)))

from operator import mul

from functools import reduce

def cmb(n,r):

    r = min(n-r,r)

    if r == 0: return 1

    over = reduce(mul, list(range(n, n - r, -1)))

    under = reduce(mul, list(range(1,r + 1)))

    return over // under



from collections import Counter

n = int(eval(input()))

list_N = []

ans = 0



for _ in range(n):

    s = sorted(eval(input()))

    list_N.append("".join(s))



list_M = list(Counter(list_N).values())



for i in list_M:

    if i != 1:

        ans += cmb(i, 2)

print(ans)
import math

n = int(eval(input()))
list_voc = [str(eval(input())) for _ in range(n)]
list_mo = []
for i, s in enumerate(list_voc):
    list_n = list(s)
    list_n.sort()
    list_n = "".join(list_n)
    list_mo.append(list_n)
ans = {}
for s in list_mo:
    if s in ans:
        ans[s] += 1
    else:
        ans[s] = 1
ans_val = []


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


for s in ans:
    if ans[s] != 1:
        ans_val.append(cmb(ans[s], 2))
print((sum(ans_val)))

from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, list(range(n, n - r, -1)))
    under = reduce(mul, list(range(1, r + 1)))
    return over // under


from collections import Counter

n = int(eval(input()))
list_N = []
ans = 0
for _ in range(n):
    s = sorted(eval(input()))
    list_N.append("".join(s))
list_M = list(Counter(list_N).values())
for i in list_M:
    if i != 1:
        ans += cmb(i, 2)
print(ans)

-import math - -n = int(eval(input())) -list_voc = [str(eval(input())) for _ in range(n)] -list_mo = [] -for i, s in enumerate(list_voc): -    list_n = list(s) -    list_n.sort() -    list_n = "".join(list_n) -    list_mo.append(list_n) -ans = {} -for s in list_mo: -    if s in ans: -        ans[s] += 1 -    else: -        ans[s] = 1 -ans_val = [] +from operator import mul +from functools import reduce -    if n - r < r: -        r = n - r +    r = min(n - r, r) -    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 +    over = reduce(mul, list(range(n, n - r, -1))) +    under = reduce(mul, list(range(1, r + 1))) +    return over // under -for s in ans: -    if ans[s] != 1: -        ans_val.append(cmb(ans[s], 2)) -print((sum(ans_val))) +from collections import Counter + +n = int(eval(input())) +list_N = [] +ans = 0 +for _ in range(n): +    s = sorted(eval(input())) +    list_N.append("".join(s)) +list_M = list(Counter(list_N).values()) +for i in list_M: +    if i != 1: +        ans += cmb(i, 2) +print(ans)