N = int(eval(input()))

words = []

for i in range(N):

  s = str(eval(input()))

  s_sort = ''.join(sorted([ch for ch in s]))

  words.append(s_sort)



words_sort = sorted(words)



counter = 0

target_word = ''

counts = []

for word in words_sort:

  if word == target_word:

    counter += 1

  else:

    counts.append(counter)

    counter = 1

    target_word = word



counts.append(counter)



from math import factorial



ans = 0

for cnt in counts:

  if cnt > 1:

    ans += factorial(cnt) // factorial(cnt-2) // 2



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

words = []

for i in range(N):

  s_in = str(eval(input()))

  s_sort = ''.join(sorted([ch for ch in s_in]))

  words.append(s_sort)

#print(words)



# Counterクラス: key=要素, val=出現回数

from collections import Counter

cntr = Counter(words)

#print(cntr)



# 出現回数2個以上は組み合わせ数を足す

ans = 0

for cnt in list(cntr.values()):

  if cnt > 1:

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



print(ans)
N = int(eval(input()))
words = []
for i in range(N):
    s = str(eval(input()))
    s_sort = "".join(sorted([ch for ch in s]))
    words.append(s_sort)
words_sort = sorted(words)
counter = 0
target_word = ""
counts = []
for word in words_sort:
    if word == target_word:
        counter += 1
    else:
        counts.append(counter)
        counter = 1
        target_word = word
counts.append(counter)
from math import factorial

ans = 0
for cnt in counts:
    if cnt > 1:
        ans += factorial(cnt) // factorial(cnt - 2) // 2
print(ans)

N = int(eval(input()))
words = []
for i in range(N):
    s_in = str(eval(input()))
    s_sort = "".join(sorted([ch for ch in s_in]))
    words.append(s_sort)
# print(words)
# Counterクラス: key=要素, val=出現回数
from collections import Counter

cntr = Counter(words)
# print(cntr)
# 出現回数2個以上は組み合わせ数を足す
ans = 0
for cnt in list(cntr.values()):
    if cnt > 1:
        ans += cnt * (cnt - 1) // 2
print(ans)

-    s = str(eval(input())) -    s_sort = "".join(sorted([ch for ch in s])) +    s_in = str(eval(input())) +    s_sort = "".join(sorted([ch for ch in s_in])) -words_sort = sorted(words) -counter = 0 -target_word = "" -counts = [] -for word in words_sort: -    if word == target_word: -        counter += 1 -    else: -        counts.append(counter) -        counter = 1 -        target_word = word -counts.append(counter) -from math import factorial +# print(words) +# Counterクラス: key=要素, val=出現回数 +from collections import Counter +cntr = Counter(words) +# print(cntr) +# 出現回数2個以上は組み合わせ数を足す -for cnt in counts: +for cnt in list(cntr.values()): -        ans += factorial(cnt) // factorial(cnt - 2) // 2 +        ans += cnt * (cnt - 1) // 2