alphabet = "abcdefghijklmnopqrstuvwxyz"





n = int(eval(input()))

res = dict()

for _ in range(n):

    s = str(eval(input()))

    freqency = [0 for _ in alphabet]

    for __ in s:

        freqency[alphabet.index(__)] += 1

    freq = "".join([str(___) for ___ in freqency])

    if freq not in res:

        res[freq] = 1

    else:

        res[freq] += 1



ans = 0

for value in list(res.values()):

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

  

print((int(ans)))
alphabet = "abcdefghijklmnopqrstuvwxyz"





n = int(eval(input()))

res = dict()

ans = 0

for _ in range(n):

    s = str(eval(input()))

    s = "".join(sorted(s))

    if s not in list(res.keys()):

      res[s] = 1

    else:

      ans += res[s]

      res[s] += 1

print(ans)

      
alphabet = "abcdefghijklmnopqrstuvwxyz"
n = int(eval(input()))
res = dict()
for _ in range(n):
    s = str(eval(input()))
    freqency = [0 for _ in alphabet]
    for __ in s:
        freqency[alphabet.index(__)] += 1
    freq = "".join([str(___) for ___ in freqency])
    if freq not in res:
        res[freq] = 1
    else:
        res[freq] += 1
ans = 0
for value in list(res.values()):
    ans += ((value - 1) * value) / 2
print((int(ans)))

alphabet = "abcdefghijklmnopqrstuvwxyz"
n = int(eval(input()))
res = dict()
ans = 0
for _ in range(n):
    s = str(eval(input()))
    s = "".join(sorted(s))
    if s not in list(res.keys()):
        res[s] = 1
    else:
        ans += res[s]
        res[s] += 1
print(ans)

+ans = 0 -    freqency = [0 for _ in alphabet] -    for __ in s: -        freqency[alphabet.index(__)] += 1 -    freq = "".join([str(___) for ___ in freqency]) -    if freq not in res: -        res[freq] = 1 +    s = "".join(sorted(s)) +    if s not in list(res.keys()): +        res[s] = 1 -        res[freq] += 1 -ans = 0 -for value in list(res.values()): -    ans += ((value - 1) * value) / 2 -print((int(ans))) +        ans += res[s] +        res[s] += 1 +print(ans)