#from Collections import Counter



N = int(eval(input()))

count = 0

word = {}

def str_sort(str):

    f = lambda y: "".join(sorted([x.replace(' ', '').lower() for x in y]))

    return f(str)

for _ in range(N):

    sorted_str = str_sort(eval(input()))

    if sorted_str not in word:

        word[sorted_str] = [0]

        word[sorted_str].append(1)

    else:

        if word[sorted_str] == 0:

            word[sorted_str][0] = 1

        else:

            word[sorted_str][0] += word[sorted_str][1]

            word[sorted_str][1] += 1

            #word[sorted_str] = word[sorted_str][0] + word[sorted_str][1]

total = sum(

    v[0] for v in list(word.values())

)

#print(word)

print(total)

from collections import Counter

from math import factorial

#from scipy.special import comb

def com(n , r):

    if n == 1:

        return 0

    else:

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

N = int(eval(input()))

S = []

for _ in range(N):

    s = eval(input())

    S.append("".join(sorted(s)))

CS = Counter(S)

ans = 0

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

    ans += com(val , 2 )

print(ans)
# from Collections import Counter
N = int(eval(input()))
count = 0
word = {}


def str_sort(str):
    f = lambda y: "".join(sorted([x.replace(" ", "").lower() for x in y]))
    return f(str)


for _ in range(N):
    sorted_str = str_sort(eval(input()))
    if sorted_str not in word:
        word[sorted_str] = [0]
        word[sorted_str].append(1)
    else:
        if word[sorted_str] == 0:
            word[sorted_str][0] = 1
        else:
            word[sorted_str][0] += word[sorted_str][1]
            word[sorted_str][1] += 1
            # word[sorted_str] = word[sorted_str][0] + word[sorted_str][1]
total = sum(v[0] for v in list(word.values()))
# print(word)
print(total)

from collections import Counter
from math import factorial

# from scipy.special import comb
def com(n, r):
    if n == 1:
        return 0
    else:
        return factorial(n) // (factorial(n - r) * factorial(r))


N = int(eval(input()))
S = []
for _ in range(N):
    s = eval(input())
    S.append("".join(sorted(s)))
CS = Counter(S)
ans = 0
for val in list(CS.values()):
    ans += com(val, 2)
print(ans)

-# from Collections import Counter -N = int(eval(input())) -count = 0 -word = {} +from collections import Counter +from math import factorial + +# from scipy.special import comb +def com(n, r): +    if n == 1: +        return 0 +    else: +        return factorial(n) // (factorial(n - r) * factorial(r)) -def str_sort(str): -    f = lambda y: "".join(sorted([x.replace(" ", "").lower() for x in y])) -    return f(str) - - +N = int(eval(input())) +S = [] -    sorted_str = str_sort(eval(input())) -    if sorted_str not in word: -        word[sorted_str] = [0] -        word[sorted_str].append(1) -    else: -        if word[sorted_str] == 0: -            word[sorted_str][0] = 1 -        else: -            word[sorted_str][0] += word[sorted_str][1] -            word[sorted_str][1] += 1 -            # word[sorted_str] = word[sorted_str][0] + word[sorted_str][1] -total = sum(v[0] for v in list(word.values())) -# print(word) -print(total) +    s = eval(input()) +    S.append("".join(sorted(s))) +CS = Counter(S) +ans = 0 +for val in list(CS.values()): +    ans += com(val, 2) +print(ans)