from collections import defaultdict





N = int(eval(input()))

dic = defaultdict(int)

ans = 0

for _ in range(N):

    elem = str(sorted(eval(input())))

    ans += dic[elem]

    dic[elem] += 1

print(ans)

import sys

from collections import defaultdict





def input():

    return sys.stdin.readline().strip()





N = int(eval(input()))

dic = defaultdict(int)

ans = 0

for _ in range(N):

    elem = str(sorted(eval(input())))

    ans += dic[elem]

    dic[elem] += 1

print(ans)

from collections import defaultdict

N = int(eval(input()))
dic = defaultdict(int)
ans = 0
for _ in range(N):
    elem = str(sorted(eval(input())))
    ans += dic[elem]
    dic[elem] += 1
print(ans)

import sys
from collections import defaultdict


def input():
    return sys.stdin.readline().strip()


N = int(eval(input()))
dic = defaultdict(int)
ans = 0
for _ in range(N):
    elem = str(sorted(eval(input())))
    ans += dic[elem]
    dic[elem] += 1
print(ans)

+import sys + + +def input(): +    return sys.stdin.readline().strip() +