from collections import Counter

from collections import defaultdict

N = int(eval(input()))

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

d = defaultdict(lambda : 0)

ans = 0

for s in S:

    c = sorted(Counter(s).items())

    ans += d[str(c)]

    d[str(c)]+=1

print(ans)
from collections import defaultdict

N = int(eval(input()))

d = defaultdict(int)

ans = 0

for i in range(N):

    S = list(eval(input()))

    S.sort()

    s = "".join(S)

    ans += d[s]

    d[s]+=1

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

N = int(eval(input()))
S = [eval(input()) for i in range(N)]
d = defaultdict(lambda: 0)
ans = 0
for s in S:
    c = sorted(Counter(s).items())
    ans += d[str(c)]
    d[str(c)] += 1
print(ans)

from collections import defaultdict

N = int(eval(input()))
d = defaultdict(int)
ans = 0
for i in range(N):
    S = list(eval(input()))
    S.sort()
    s = "".join(S)
    ans += d[s]
    d[s] += 1
print(ans)

-from collections import Counter -S = [eval(input()) for i in range(N)] -d = defaultdict(lambda: 0) +d = defaultdict(int) -for s in S: -    c = sorted(Counter(s).items()) -    ans += d[str(c)] -    d[str(c)] += 1 +for i in range(N): +    S = list(eval(input())) +    S.sort() +    s = "".join(S) +    ans += d[s] +    d[s] += 1