import sys

N=int(eval(input()))

ans,c=0,{}

for _ in range(N):

    s=''.join(sorted(next(sys.stdin)))

    if s not in c:

         c[s]=0

    ans+=c[s]

    c[s]+=1

print(ans)

import sys

eval(input())

ans,c=0,{}

for ln in sys.stdin:

    s=''.join(sorted(ln))

    ans+=c.setdefault(s,0)

    c[s]+=1

print(ans)

import sys

N = int(eval(input()))
ans, c = 0, {}
for _ in range(N):
    s = "".join(sorted(next(sys.stdin)))
    if s not in c:
        c[s] = 0
    ans += c[s]
    c[s] += 1
print(ans)

import sys

eval(input())
ans, c = 0, {}
for ln in sys.stdin:
    s = "".join(sorted(ln))
    ans += c.setdefault(s, 0)
    c[s] += 1
print(ans)

-N = int(eval(input())) +eval(input()) -for _ in range(N): -    s = "".join(sorted(next(sys.stdin))) -    if s not in c: -        c[s] = 0 -    ans += c[s] +for ln in sys.stdin: +    s = "".join(sorted(ln)) +    ans += c.setdefault(s, 0)