N=int(eval(input()))

dic={}

cnt=0

for i in range(N):

    temp=' '.join(sorted(eval(input())))

    if temp in dic:

        dic[temp]+=1

    else:

        dic[temp]=1

for j in list(dic.values()):

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

print(cnt)

import sys

input = sys.stdin.readline



n = int(eval(input()))



from collections import defaultdict



d = defaultdict(int)



for i in range(n):

    s = list(input().rstrip())

    s.sort()

    d["".join(s)] += 1



ans = 0



for i in list(d.keys()):

    ans += d[i]*(d[i] - 1)//2



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

import sys

input = sys.stdin.readline
n = int(eval(input()))
from collections import defaultdict

d = defaultdict(int)
for i in range(n):
    s = list(input().rstrip())
    s.sort()
    d["".join(s)] += 1
ans = 0
for i in list(d.keys()):
    ans += d[i] * (d[i] - 1) // 2
print(ans)

-N = int(eval(input())) -dic = {} -cnt = 0 -for i in range(N): -    temp = " ".join(sorted(eval(input()))) -    if temp in dic: -        dic[temp] += 1 -    else: -        dic[temp] = 1 -for j in list(dic.values()): -    cnt += j * (j - 1) // 2 -print(cnt) +import sys + +input = sys.stdin.readline +n = int(eval(input())) +from collections import defaultdict + +d = defaultdict(int) +for i in range(n): +    s = list(input().rstrip()) +    s.sort() +    d["".join(s)] += 1 +ans = 0 +for i in list(d.keys()): +    ans += d[i] * (d[i] - 1) // 2 +print(ans)