n = int(eval(input()))



S = []

for _ in range(n):

    s = list(eval(input()))

    s.sort()

    S.append("".join(s))

S.sort()



C = []

c = 1

for i in range(n - 1):

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

        c += 1

    else:

        C.append(c)

        c = 1

C.append(c)



ans = 0

for c in C:

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



print(ans)

import sys

input = sys.stdin.readline





n = int(eval(input()))



S = []

for _ in range(n):

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

    S.append(s)

S.sort()





answer = 0

count = 1

for i in range(n - 1):

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

        count += 1

    else:

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

        count = 1

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





print(answer)

n = int(eval(input()))
S = []
for _ in range(n):
    s = list(eval(input()))
    s.sort()
    S.append("".join(s))
S.sort()
C = []
c = 1
for i in range(n - 1):
    if S[i] == S[i + 1]:
        c += 1
    else:
        C.append(c)
        c = 1
C.append(c)
ans = 0
for c in C:
    ans += c * (c - 1) // 2
print(ans)

import sys

input = sys.stdin.readline
n = int(eval(input()))
S = []
for _ in range(n):
    s = "".join(sorted(input().strip()))
    S.append(s)
S.sort()
answer = 0
count = 1
for i in range(n - 1):
    if S[i] == S[i + 1]:
        count += 1
    else:
        answer += count * (count - 1) // 2
        count = 1
answer += count * (count - 1) // 2
print(answer)

+import sys + +input = sys.stdin.readline -    s = list(eval(input())) -    s.sort() -    S.append("".join(s)) +    s = "".join(sorted(input().strip())) +    S.append(s) -C = [] -c = 1 +answer = 0 +count = 1 -        c += 1 +        count += 1 -        C.append(c) -        c = 1 -C.append(c) -ans = 0 -for c in C: -    ans += c * (c - 1) // 2 -print(ans) +        answer += count * (count - 1) // 2 +        count = 1 +answer += count * (count - 1) // 2 +print(answer)