from scipy.misc import comb

from collections import Counter

N = int(eval(input()))

S = [eval(input()) for _ in range(N)]

chars = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

result = []

for n in range(N):

    res = {}

    for char in chars:

        res[char] = S[n].count(char)

    result.append(res)

result2 = Counter([str(i) for i in result ])

cnt = 0

for key in list(result2.keys()):

    if result2[key] == 1:

        pass

    else:

        cnt += comb(result2[key],2,exact=True)

print((int(cnt)))
N = int(eval(input()))

S = [""] * N

for n in range(N):

    S[n] = eval(input())

from collections import defaultdict

dct = defaultdict(int)

for s in S:

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

    dct[sorted_s] += 1

ans = 0

for k,v in list(dct.items()):

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

print(ans)

from scipy.misc import comb
from collections import Counter

N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
chars = [
    "a",
    "b",
    "c",
    "d",
    "e",
    "f",
    "g",
    "h",
    "i",
    "j",
    "k",
    "l",
    "m",
    "n",
    "o",
    "p",
    "q",
    "r",
    "s",
    "t",
    "u",
    "v",
    "w",
    "x",
    "y",
    "z",
]
result = []
for n in range(N):
    res = {}
    for char in chars:
        res[char] = S[n].count(char)
    result.append(res)
result2 = Counter([str(i) for i in result])
cnt = 0
for key in list(result2.keys()):
    if result2[key] == 1:
        pass
    else:
        cnt += comb(result2[key], 2, exact=True)
print((int(cnt)))

N = int(eval(input()))
S = [""] * N
for n in range(N):
    S[n] = eval(input())
from collections import defaultdict

dct = defaultdict(int)
for s in S:
    sorted_s = "".join(sorted(s))
    dct[sorted_s] += 1
ans = 0
for k, v in list(dct.items()):
    ans += v * (v - 1) // 2
print(ans)

-from scipy.misc import comb -from collections import Counter +N = int(eval(input())) +S = [""] * N +for n in range(N): +    S[n] = eval(input()) +from collections import defaultdict -N = int(eval(input())) -S = [eval(input()) for _ in range(N)] -chars = [ -    "a", -    "b", -    "c", -    "d", -    "e", -    "f", -    "g", -    "h", -    "i", -    "j", -    "k", -    "l", -    "m", -    "n", -    "o", -    "p", -    "q", -    "r", -    "s", -    "t", -    "u", -    "v", -    "w", -    "x", -    "y", -    "z", -] -result = [] -for n in range(N): -    res = {} -    for char in chars: -        res[char] = S[n].count(char) -    result.append(res) -result2 = Counter([str(i) for i in result]) -cnt = 0 -for key in list(result2.keys()): -    if result2[key] == 1: -        pass -    else: -        cnt += comb(result2[key], 2, exact=True) -print((int(cnt))) +dct = defaultdict(int) +for s in S: +    sorted_s = "".join(sorted(s)) +    dct[sorted_s] += 1 +ans = 0 +for k, v in list(dct.items()): +    ans += v * (v - 1) // 2 +print(ans)