n = int(eval(input()))

d={}

for i in range(n):

    s=str(sorted(eval(input())))

    try:

        d[s]+=1

    except:

        d[s]=1

ans=0



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

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

print(ans)
import collections



ss = []





N = int(eval(input()))

for i in range(N):

    s = str(sorted(eval(input())))

    ss.append(s)



c = collections.Counter(ss)

ans = 0



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

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

print(ans)

n = int(eval(input()))
d = {}
for i in range(n):
    s = str(sorted(eval(input())))
    try:
        d[s] += 1
    except:
        d[s] = 1
ans = 0
for i in list(d.values()):
    ans += i * (i - 1) // 2
print(ans)

import collections

ss = []
N = int(eval(input()))
for i in range(N):
    s = str(sorted(eval(input())))
    ss.append(s)
c = collections.Counter(ss)
ans = 0
for v in list(c.values()):
    ans += v * (v - 1) // 2
print(ans)

-n = int(eval(input())) -d = {} -for i in range(n): +import collections + +ss = [] +N = int(eval(input())) +for i in range(N): -    try: -        d[s] += 1 -    except: -        d[s] = 1 +    ss.append(s) +c = collections.Counter(ss) -for i in list(d.values()): -    ans += i * (i - 1) // 2 +for v in list(c.values()): +    ans += v * (v - 1) // 2