n=int(eval(input()))

slist=[]

for i in range(n):

    s10=eval(input())

    si=[]

    for ii in range(10):

        si.append(s10[ii])

    si.sort()

    stmp=""

    for ii in range(10):

        stmp=stmp+si[ii]

    slist.append(stmp)

slist.sort()

    

icnt=0   

i=0 

while i<=n-2:

    j=i+1

    jcnt=0

    while slist[i]==slist[j]:

        jcnt=jcnt+1

        icnt=icnt+jcnt

        j=j+1

        if j>=n:

            break

    i=j

    if i>=n-1:

        break

            

print(icnt)  


n=int(eval(input()))

st=dict()

for i in range(n):

    si=list(eval(input()))

    si.sort()

    si="".join(si)

    if si in st:

        st[si]+=1

    else:

        st[si]=1

        

icnt=0

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

    if i>1:

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

        

print(icnt)

    
n = int(eval(input()))
slist = []
for i in range(n):
    s10 = eval(input())
    si = []
    for ii in range(10):
        si.append(s10[ii])
    si.sort()
    stmp = ""
    for ii in range(10):
        stmp = stmp + si[ii]
    slist.append(stmp)
slist.sort()
icnt = 0
i = 0
while i <= n - 2:
    j = i + 1
    jcnt = 0
    while slist[i] == slist[j]:
        jcnt = jcnt + 1
        icnt = icnt + jcnt
        j = j + 1
        if j >= n:
            break
    i = j
    if i >= n - 1:
        break
print(icnt)

n = int(eval(input()))
st = dict()
for i in range(n):
    si = list(eval(input()))
    si.sort()
    si = "".join(si)
    if si in st:
        st[si] += 1
    else:
        st[si] = 1
icnt = 0
for i in list(st.values()):
    if i > 1:
        icnt += i * (i - 1) // 2
print(icnt)

-slist = [] +st = dict() -    s10 = eval(input()) -    si = [] -    for ii in range(10): -        si.append(s10[ii]) +    si = list(eval(input())) -    stmp = "" -    for ii in range(10): -        stmp = stmp + si[ii] -    slist.append(stmp) -slist.sort() +    si = "".join(si) +    if si in st: +        st[si] += 1 +    else: +        st[si] = 1 -i = 0 -while i <= n - 2: -    j = i + 1 -    jcnt = 0 -    while slist[i] == slist[j]: -        jcnt = jcnt + 1 -        icnt = icnt + jcnt -        j = j + 1 -        if j >= n: -            break -    i = j -    if i >= n - 1: -        break +for i in list(st.values()): +    if i > 1: +        icnt += i * (i - 1) // 2