from collections import Counter,defaultdict

import sys

input = sys.stdin.readline



N = int(eval(input()))

s = [None] + [list(eval(input())) for _ in range(N)]



count = defaultdict(int)



answer = 0

for i in range(1,N+1):

    c = Counter(s[i])

    c = sorted(list(c.items()), key=lambda x:x[0])

    # O(len(c))

    str_c = ""

    for key,item in c:

        str_c += key*item

    answer += count[str_c]

    count[str_c] += 1



print(answer)
from collections import defaultdict



N = int(eval(input()))



cnt = defaultdict(int)



ans = 0

for _ in range(N):

    s = list(eval(input()))

    s.sort()

    s = str(s)

    ans += cnt[s]

    cnt[s] += 1



print(ans)
from collections import Counter, defaultdict
import sys

input = sys.stdin.readline
N = int(eval(input()))
s = [None] + [list(eval(input())) for _ in range(N)]
count = defaultdict(int)
answer = 0
for i in range(1, N + 1):
    c = Counter(s[i])
    c = sorted(list(c.items()), key=lambda x: x[0])
    # O(len(c))
    str_c = ""
    for key, item in c:
        str_c += key * item
    answer += count[str_c]
    count[str_c] += 1
print(answer)

from collections import defaultdict

N = int(eval(input()))
cnt = defaultdict(int)
ans = 0
for _ in range(N):
    s = list(eval(input()))
    s.sort()
    s = str(s)
    ans += cnt[s]
    cnt[s] += 1
print(ans)

-from collections import Counter, defaultdict -import sys +from collections import defaultdict -input = sys.stdin.readline -s = [None] + [list(eval(input())) for _ in range(N)] -count = defaultdict(int) -answer = 0 -for i in range(1, N + 1): -    c = Counter(s[i]) -    c = sorted(list(c.items()), key=lambda x: x[0]) -    # O(len(c)) -    str_c = "" -    for key, item in c: -        str_c += key * item -    answer += count[str_c] -    count[str_c] += 1 -print(answer) +cnt = defaultdict(int) +ans = 0 +for _ in range(N): +    s = list(eval(input())) +    s.sort() +    s = str(s) +    ans += cnt[s] +    cnt[s] += 1 +print(ans)