N = int(eval(input()))

s = list(list(eval(input())) for i in range(N))

for i in range(N):

    s[i].sort()

s.sort()

ans = 0

same = 1

for i in range(1,N):

    if s[i] == s[i-1]:

        ans += same

        same += 1

    else:

        same = 1

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

S = []

for _ in range(N):

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

D = {}

count = 0

for i in S:

    if i in D:

        count += D[i]

        D[i] += 1

    else:

        D[i] = 1

print(count)
N = int(eval(input()))
s = list(list(eval(input())) for i in range(N))
for i in range(N):
    s[i].sort()
s.sort()
ans = 0
same = 1
for i in range(1, N):
    if s[i] == s[i - 1]:
        ans += same
        same += 1
    else:
        same = 1
print(ans)

N = int(eval(input()))
S = []
for _ in range(N):
    S.append("".join(sorted(eval(input()))))
D = {}
count = 0
for i in S:
    if i in D:
        count += D[i]
        D[i] += 1
    else:
        D[i] = 1
print(count)

-s = list(list(eval(input())) for i in range(N)) -for i in range(N): -    s[i].sort() -s.sort() -ans = 0 -same = 1 -for i in range(1, N): -    if s[i] == s[i - 1]: -        ans += same -        same += 1 +S = [] +for _ in range(N): +    S.append("".join(sorted(eval(input())))) +D = {} +count = 0 +for i in S: +    if i in D: +        count += D[i] +        D[i] += 1 -        same = 1 -print(ans) +        D[i] = 1 +print(count)