import collections

n = int(eval(input()))

s = [[0 for j in range(10)] for i in range(n)]

for i in range(n):

    t = eval(input())

    s[i] = "".join(sorted(t))

ans = 0



c = collections.Counter(s)

for i in set(s):

    n = c[i]

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

print(ans)
import collections

n = int(eval(input()))

s = ["".join(sorted(eval(input()))) for i in range(n)]

ans = 0



c = collections.Counter(s)

for i in set(s):

    n = c[i]

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

print(ans)
import collections

n = int(eval(input()))
s = [[0 for j in range(10)] for i in range(n)]
for i in range(n):
    t = eval(input())
    s[i] = "".join(sorted(t))
ans = 0
c = collections.Counter(s)
for i in set(s):
    n = c[i]
    ans += n * (n - 1) // 2
print(ans)

import collections

n = int(eval(input()))
s = ["".join(sorted(eval(input()))) for i in range(n)]
ans = 0
c = collections.Counter(s)
for i in set(s):
    n = c[i]
    ans += n * (n - 1) // 2
print(ans)

-s = [[0 for j in range(10)] for i in range(n)] -for i in range(n): -    t = eval(input()) -    s[i] = "".join(sorted(t)) +s = ["".join(sorted(eval(input()))) for i in range(n)]