n=int(eval(input()))

dictionary=[]

count=1

ans=0

for i in range(n):

    s=list(eval(input()))

    s.sort()

    dictionary.append(s)

dictionary.sort()

for i in range(n-1):

    if dictionary[i]==dictionary[i+1]:

        count+=1

    else:

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

        count=1

    if i==n-2:

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

print(ans)

n = int(eval(input()))

d = dict()

for i in range(n):

    s = list(eval(input()))

    s.sort()

    s = "".join(s)

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

        d[s] = 1

    else:

        d[s] += 1

count = 0

for i in list(d.values()):

    count += i * (i-1) // 2

print(count)
n = int(eval(input()))
dictionary = []
count = 1
ans = 0
for i in range(n):
    s = list(eval(input()))
    s.sort()
    dictionary.append(s)
dictionary.sort()
for i in range(n - 1):
    if dictionary[i] == dictionary[i + 1]:
        count += 1
    else:
        ans += count * (count - 1) // 2
        count = 1
    if i == n - 2:
        ans += count * (count - 1) // 2
print(ans)

n = int(eval(input()))
d = dict()
for i in range(n):
    s = list(eval(input()))
    s.sort()
    s = "".join(s)
    if s not in list(d.keys()):
        d[s] = 1
    else:
        d[s] += 1
count = 0
for i in list(d.values()):
    count += i * (i - 1) // 2
print(count)

-dictionary = [] -count = 1 -ans = 0 +d = dict() -    dictionary.append(s) -dictionary.sort() -for i in range(n - 1): -    if dictionary[i] == dictionary[i + 1]: -        count += 1 +    s = "".join(s) +    if s not in list(d.keys()): +        d[s] = 1 -        ans += count * (count - 1) // 2 -        count = 1 -    if i == n - 2: -        ans += count * (count - 1) // 2 -print(ans) +        d[s] += 1 +count = 0 +for i in list(d.values()): +    count += i * (i - 1) // 2 +print(count)