n = int(eval(input()))

ans = 0

used_s = {}

for _ in range(n):

    s = "".join(sorted(eval(input())))

    if not s in list(used_s.keys()):

        used_s[s] = 0

    else:

        used_s[s] += 1

        ans += 1 * used_s[s]



print(ans)
import sys

input = sys.stdin.readline



n = int(eval(input()))

ans = 0

used_s = {}

for _ in range(n):

    s = "".join(sorted(eval(input())))

    if not s in list(used_s.keys()):

        used_s[s] = 0

    else:

        used_s[s] += 1

        ans += 1 * used_s[s]



print(ans)
n = int(eval(input()))
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(eval(input())))
    if not s in list(used_s.keys()):
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]
print(ans)

import sys

input = sys.stdin.readline
n = int(eval(input()))
ans = 0
used_s = {}
for _ in range(n):
    s = "".join(sorted(eval(input())))
    if not s in list(used_s.keys()):
        used_s[s] = 0
    else:
        used_s[s] += 1
        ans += 1 * used_s[s]
print(ans)

+import sys + +input = sys.stdin.readline