n = int(eval(input()))

l = []

for i in range(n):

  l.append(''.join(sorted(eval(input()))))

l.sort()



cnt = 0

ans = 0

for i in range(n-1):

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

    cnt += 1

    ans += cnt

  else:

    cnt = 0

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

l = [''.join(sorted(eval(input()))) for _ in range(n)]



d = {}

ans = 0



for s in l:

  if s in d:

    d[s] += 1

    ans += d[s]-1

  else:

    d[s] = 1



print(ans)
n = int(eval(input()))
l = []
for i in range(n):
    l.append("".join(sorted(eval(input()))))
l.sort()
cnt = 0
ans = 0
for i in range(n - 1):
    if l[i + 1] == l[i]:
        cnt += 1
        ans += cnt
    else:
        cnt = 0
print(ans)

n = int(eval(input()))
l = ["".join(sorted(eval(input()))) for _ in range(n)]
d = {}
ans = 0
for s in l:
    if s in d:
        d[s] += 1
        ans += d[s] - 1
    else:
        d[s] = 1
print(ans)

-l = [] -for i in range(n): -    l.append("".join(sorted(eval(input())))) -l.sort() -cnt = 0 +l = ["".join(sorted(eval(input()))) for _ in range(n)] +d = {} -for i in range(n - 1): -    if l[i + 1] == l[i]: -        cnt += 1 -        ans += cnt +for s in l: +    if s in d: +        d[s] += 1 +        ans += d[s] - 1 -        cnt = 0 +        d[s] = 1