n = int(eval(input()))



s = []

for _ in range(n):

    s += [''.join(map(str, (sorted(list(str(eval(input())))))))]



import collections



c = collections.Counter(s)



from math import factorial



ans = 0



for x in list(c.values()):

    if x >= 2:

        ans += factorial(x)//(factorial(x-2)*2)



print(ans)

n = int(eval(input()))



s = []

for _ in range(n):

    s += [''.join(map(str, (sorted(list(str(eval(input())))))))]



import collections



c = collections.Counter(s)



ans = 0



for x in list(c.values()):

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



print(ans)

n = int(eval(input()))
s = []
for _ in range(n):
    s += ["".join(map(str, (sorted(list(str(eval(input())))))))]
import collections

c = collections.Counter(s)
from math import factorial

ans = 0
for x in list(c.values()):
    if x >= 2:
        ans += factorial(x) // (factorial(x - 2) * 2)
print(ans)

n = int(eval(input()))
s = []
for _ in range(n):
    s += ["".join(map(str, (sorted(list(str(eval(input())))))))]
import collections

c = collections.Counter(s)
ans = 0
for x in list(c.values()):
    ans += x * (x - 1) // 2
print(ans)

-from math import factorial - -    if x >= 2: -        ans += factorial(x) // (factorial(x - 2) * 2) +    ans += x * (x - 1) // 2