from collections import defaultdict

N = int(eval(input()))

H = defaultdict(int)

for _ in range(N):

  S = eval(input())

  C = [0] * 26

  for s in S:

    C[ord(s) - 97] += 1

  H[str(C)] += 1

cnt = 0

for v in list(H.values()):

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

print(cnt)
from collections import defaultdict

N = int(eval(input()))

H = defaultdict(int)

for _ in range(N):

  S = eval(input())

  H[''.join(sorted([s for s in S]))] += 1

cnt = 0

for v in list(H.values()):

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

print(cnt)
from collections import defaultdict

N = int(eval(input()))
H = defaultdict(int)
for _ in range(N):
    S = eval(input())
    C = [0] * 26
    for s in S:
        C[ord(s) - 97] += 1
    H[str(C)] += 1
cnt = 0
for v in list(H.values()):
    cnt += v * (v - 1) // 2
print(cnt)

from collections import defaultdict

N = int(eval(input()))
H = defaultdict(int)
for _ in range(N):
    S = eval(input())
    H["".join(sorted([s for s in S]))] += 1
cnt = 0
for v in list(H.values()):
    cnt += v * (v - 1) // 2
print(cnt)

-    C = [0] * 26 -    for s in S: -        C[ord(s) - 97] += 1 -    H[str(C)] += 1 +    H["".join(sorted([s for s in S]))] += 1