# coding: utf-8

# Your code here!



import collections

n = int(eval(input()))



sl = []

for _ in range(n):

    s = sorted(list(eval(input())))

    sl.append(s)



before_s = ""

ans = 0

point = 1

for i in sorted(sl):

    if i == before_s:

        point += 1

    else:

        before_s = i

        ans += int(point * (point - 1) / 2)

        point = 1

ans += int(point * (point - 1) / 2)

print(ans)

    

n = int(eval(input()))



from collections import defaultdict

dic = defaultdict(int)



for _ in range(n):

    s = list(eval(input()))

    s = tuple(sorted(s))

    dic[s] += 1



ans = 0

for s in dic:

    ans += dic[s] * (dic[s] - 1) // 2



print(ans)







# coding: utf-8
# Your code here!
import collections

n = int(eval(input()))
sl = []
for _ in range(n):
    s = sorted(list(eval(input())))
    sl.append(s)
before_s = ""
ans = 0
point = 1
for i in sorted(sl):
    if i == before_s:
        point += 1
    else:
        before_s = i
        ans += int(point * (point - 1) / 2)
        point = 1
ans += int(point * (point - 1) / 2)
print(ans)

n = int(eval(input()))
from collections import defaultdict

dic = defaultdict(int)
for _ in range(n):
    s = list(eval(input()))
    s = tuple(sorted(s))
    dic[s] += 1
ans = 0
for s in dic:
    ans += dic[s] * (dic[s] - 1) // 2
print(ans)

-# coding: utf-8 -# Your code here! -import collections +n = int(eval(input())) +from collections import defaultdict -n = int(eval(input())) -sl = [] +dic = defaultdict(int) -    s = sorted(list(eval(input()))) -    sl.append(s) -before_s = "" +    s = list(eval(input())) +    s = tuple(sorted(s)) +    dic[s] += 1 -point = 1 -for i in sorted(sl): -    if i == before_s: -        point += 1 -    else: -        before_s = i -        ans += int(point * (point - 1) / 2) -        point = 1 -ans += int(point * (point - 1) / 2) +for s in dic: +    ans += dic[s] * (dic[s] - 1) // 2