N = int(eval(input()))



dic = {}



for i in range(N):

	s = eval(input())

	s = ''.join(sorted(s))

	if s in dic:

		dic[s] += int((-1+(1+8*(dic[s]))**0.5)/2)+1

	else:

		dic[s] = 0

print((sum(dic.values())))

import collections



n=int(eval(input()))

s = [",".join(sorted(eval(input()))) for i in range(n)]



c = collections.Counter(s)



ans=0

for i in list(c.values()):

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



print(ans)
N = int(eval(input()))
dic = {}
for i in range(N):
    s = eval(input())
    s = "".join(sorted(s))
    if s in dic:
        dic[s] += int((-1 + (1 + 8 * (dic[s])) ** 0.5) / 2) + 1
    else:
        dic[s] = 0
print((sum(dic.values())))

import collections

n = int(eval(input()))
s = [",".join(sorted(eval(input()))) for i in range(n)]
c = collections.Counter(s)
ans = 0
for i in list(c.values()):
    ans += i * (i - 1) // 2
print(ans)

-N = int(eval(input())) -dic = {} -for i in range(N): -    s = eval(input()) -    s = "".join(sorted(s)) -    if s in dic: -        dic[s] += int((-1 + (1 + 8 * (dic[s])) ** 0.5) / 2) + 1 -    else: -        dic[s] = 0 -print((sum(dic.values()))) +import collections + +n = int(eval(input())) +s = [",".join(sorted(eval(input()))) for i in range(n)] +c = collections.Counter(s) +ans = 0 +for i in list(c.values()): +    ans += i * (i - 1) // 2 +print(ans)