def cmb(n, r):

    if n - r < r: r = n - r

    if r == 0: return 1

    if r == 1: return n



    numerator = [n - r + k + 1 for k in range(r)]

    denominator = [k + 1 for k in range(r)]



    for p in range(2,r+1):

        pivot = denominator[p - 1]

        if pivot > 1:

            offset = (n - r) % p

            for k in range(p-1,r,p):

                numerator[k - offset] /= pivot

                denominator[k] /= pivot



    result = 1

    for k in range(r):

        if numerator[k] > 1:

            result *= int(numerator[k])



    return result



n = int(eval(input()))

s = [eval(input()) for i in range(n)]

for k in range(n):

    s[k]=sorted(list(s[k]))

s=sorted(s)



c = 1

count = 0



for x in range (n-1):

        if s[x]==s[x+1]:

            c += 1

        else:

            if c>= 2:

                count += cmb(c,2)

            c = 1

if c >=2:

    count += cmb(c,2)

print(count)



n = int(eval(input()))

s = [eval(input()) for i in range(n)]

for k in range(n):

    s[k]=sorted(list(s[k]))

s=sorted(s)



c = 1

count = 0



for x in range (n-1):

        if s[x]==s[x+1]:

            c += 1

        else:

            if c>= 2:

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

            c = 1

if c >=2:

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

print(count)

def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result


n = int(eval(input()))
s = [eval(input()) for i in range(n)]
for k in range(n):
    s[k] = sorted(list(s[k]))
s = sorted(s)
c = 1
count = 0
for x in range(n - 1):
    if s[x] == s[x + 1]:
        c += 1
    else:
        if c >= 2:
            count += cmb(c, 2)
        c = 1
if c >= 2:
    count += cmb(c, 2)
print(count)

n = int(eval(input()))
s = [eval(input()) for i in range(n)]
for k in range(n):
    s[k] = sorted(list(s[k]))
s = sorted(s)
c = 1
count = 0
for x in range(n - 1):
    if s[x] == s[x + 1]:
        c += 1
    else:
        if c >= 2:
            count += c * (c - 1) // 2
        c = 1
if c >= 2:
    count += c * (c - 1) // 2
print(count)

-def cmb(n, r): -    if n - r < r: -        r = n - r -    if r == 0: -        return 1 -    if r == 1: -        return n -    numerator = [n - r + k + 1 for k in range(r)] -    denominator = [k + 1 for k in range(r)] -    for p in range(2, r + 1): -        pivot = denominator[p - 1] -        if pivot > 1: -            offset = (n - r) % p -            for k in range(p - 1, r, p): -                numerator[k - offset] /= pivot -                denominator[k] /= pivot -    result = 1 -    for k in range(r): -        if numerator[k] > 1: -            result *= int(numerator[k]) -    return result - - -            count += cmb(c, 2) +            count += c * (c - 1) // 2 -    count += cmb(c, 2) +    count += c * (c - 1) // 2