n=int(eval(input()))

l=[sorted(list(eval(input()))) for i in range(n)]



d={}

for i in l:

  i=''.join(i)

  if i in d:

    d[i]+=1

  else:

    d[i]=1



ans=0

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

  if v>=2:

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

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



d={}

for i in range(n):

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

  if s in d:

    d[s]+=1

  else:

    d[s]=1



print((sum(v*(v-1)//2 for v in list(d.values()))))
n = int(eval(input()))
l = [sorted(list(eval(input()))) for i in range(n)]
d = {}
for i in l:
    i = "".join(i)
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
ans = 0
for v in list(d.values()):
    if v >= 2:
        ans += v * (v - 1) // 2
print(ans)

n = int(eval(input()))
d = {}
for i in range(n):
    s = "".join(sorted(eval(input())))
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
print((sum(v * (v - 1) // 2 for v in list(d.values()))))

-l = [sorted(list(eval(input()))) for i in range(n)] -for i in l: -    i = "".join(i) -    if i in d: -        d[i] += 1 +for i in range(n): +    s = "".join(sorted(eval(input()))) +    if s in d: +        d[s] += 1 -        d[i] = 1 -ans = 0 -for v in list(d.values()): -    if v >= 2: -        ans += v * (v - 1) // 2 -print(ans) +        d[s] = 1 +print((sum(v * (v - 1) // 2 for v in list(d.values()))))