n = int(eval(input()))

s = sorted([sorted(list(eval(input()))) for _ in range(n)])



res = 0

cnt = 1

for i in range(n-1):

    if s[i] == s[i+1]:

        res += cnt

        cnt += 1

    else:

        cnt = 1



print(res)
n = int(eval(input()))

s = [sorted(list(eval(input()))) for _ in range(n)]



res = 0

d = dict()

for list_ in s:

    str_ = str(list_)

    if str_ in d:

        d[str_] += 1

        res += d[str_] - 1

    else:

        d[str_] = 1



print(res)
n = int(eval(input()))
s = sorted([sorted(list(eval(input()))) for _ in range(n)])
res = 0
cnt = 1
for i in range(n - 1):
    if s[i] == s[i + 1]:
        res += cnt
        cnt += 1
    else:
        cnt = 1
print(res)

n = int(eval(input()))
s = [sorted(list(eval(input()))) for _ in range(n)]
res = 0
d = dict()
for list_ in s:
    str_ = str(list_)
    if str_ in d:
        d[str_] += 1
        res += d[str_] - 1
    else:
        d[str_] = 1
print(res)

-s = sorted([sorted(list(eval(input()))) for _ in range(n)]) +s = [sorted(list(eval(input()))) for _ in range(n)] -cnt = 1 -for i in range(n - 1): -    if s[i] == s[i + 1]: -        res += cnt -        cnt += 1 +d = dict() +for list_ in s: +    str_ = str(list_) +    if str_ in d: +        d[str_] += 1 +        res += d[str_] - 1 -        cnt = 1 +        d[str_] = 1