import math as m



qt = int(eval(input()))

sl = [eval(input()) for i in range(qt)]

d = {}

count = 0



for s in sl:

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

    if s in d:

        d[s] += 1

    else:

        d[s] = 1



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

    if e > 1:

        count += m.factorial(e) // (m.factorial(e - 2) * 2)



print(count)





qt = int(eval(input()))

sl = [eval(input()) for i in range(qt)]

d = {}

count = 0



for s in sl:

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

    if s in d:

        d[s] += 1

    else:

        d[s] = 1



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

    if e > 1:

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



print(count)

import math as m

qt = int(eval(input()))
sl = [eval(input()) for i in range(qt)]
d = {}
count = 0
for s in sl:
    s = "".join(sorted(s))
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
for e in list(d.values()):
    if e > 1:
        count += m.factorial(e) // (m.factorial(e - 2) * 2)
print(count)

qt = int(eval(input()))
sl = [eval(input()) for i in range(qt)]
d = {}
count = 0
for s in sl:
    s = "".join(sorted(s))
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
for e in list(d.values()):
    if e > 1:
        count += e * (e - 1) // 2
print(count)

-import math as m - -        count += m.factorial(e) // (m.factorial(e - 2) * 2) +        count += e * (e - 1) // 2