N=int(eval(input()))

S = []

for _ in range(N):

    tmp = []

    for s in eval(input()):

        tmp.append(s)

    tmp.sort()

    S.append("".join(tmp))

dic = {}

for s in S:

    if s not in dic:

        dic[s] = 0

    dic[s] += 1

ans = 0

import math

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

    if v == 1:

        continue

    p = math.factorial(v)// (math.factorial(v - 2) * math.factorial(2))

    ans += p

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

S = []

for _ in range(N):

    tmp = []

    for s in eval(input()):

        tmp.append(s)

    tmp.sort()

    S.append("".join(tmp))

dic = {}

for s in S:

    if s not in dic:

        dic[s] = 0

    dic[s] += 1

ans = 0

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

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

print((int(ans)))

N = int(eval(input()))
S = []
for _ in range(N):
    tmp = []
    for s in eval(input()):
        tmp.append(s)
    tmp.sort()
    S.append("".join(tmp))
dic = {}
for s in S:
    if s not in dic:
        dic[s] = 0
    dic[s] += 1
ans = 0
import math

for v in list(dic.values()):
    if v == 1:
        continue
    p = math.factorial(v) // (math.factorial(v - 2) * math.factorial(2))
    ans += p
print(ans)

N = int(eval(input()))
S = []
for _ in range(N):
    tmp = []
    for s in eval(input()):
        tmp.append(s)
    tmp.sort()
    S.append("".join(tmp))
dic = {}
for s in S:
    if s not in dic:
        dic[s] = 0
    dic[s] += 1
ans = 0
for v in list(dic.values()):
    ans += v * (v - 1) // 2
print((int(ans)))

-import math - -    if v == 1: -        continue -    p = math.factorial(v) // (math.factorial(v - 2) * math.factorial(2)) -    ans += p -print(ans) +    ans += v * (v - 1) // 2 +print((int(ans)))