N = int(eval(input()))

S = [list(eval(input())) for i in range(N)]



for s in S:

    s.sort()



S.sort()



cnt = 1

ans = 0

tmp = []



for s in S:

    if s == tmp:

        cnt += 1

    else:

        tmp = s

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

        cnt = 1



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



print(ans)

from collections import defaultdict



N = int(eval(input()))

S = [list(eval(input())) for i in range(N)]



d = defaultdict(int)



for s in S:

    s.sort()

    s = "".join(s)

    d[s] += 1



ans = 0



for key in list(d):

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



print(ans)

N = int(eval(input()))
S = [list(eval(input())) for i in range(N)]
for s in S:
    s.sort()
S.sort()
cnt = 1
ans = 0
tmp = []
for s in S:
    if s == tmp:
        cnt += 1
    else:
        tmp = s
        ans += cnt * (cnt - 1) // 2
        cnt = 1
ans += cnt * (cnt - 1) // 2
print(ans)

from collections import defaultdict

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

+from collections import defaultdict + +d = defaultdict(int) -S.sort() -cnt = 1 +    s = "".join(s) +    d[s] += 1 -tmp = [] -for s in S: -    if s == tmp: -        cnt += 1 -    else: -        tmp = s -        ans += cnt * (cnt - 1) // 2 -        cnt = 1 -ans += cnt * (cnt - 1) // 2 +for key in list(d): +    ans += d[key] * (d[key] - 1) // 2