from collections import defaultdict



base = ord('a')



d = defaultdict(int)



ans = 0



n = int(eval(input()))

for _ in range(n):

    s = eval(input())

    lst = [0] * 26

    for c in s:

        idx = ord(c) - base

        lst[idx] += 1

    key = tuple(lst)

    ans += d[key]

    d[key] += 1



print(ans)

from collections import defaultdict



n = int(eval(input()))

d = defaultdict(int)

ans = 0

for _ in range(n):

    s = eval(input())

    s = str(sorted(s))

    ans += d[s]

    d[s] += 1



print(ans)

from collections import defaultdict

base = ord("a")
d = defaultdict(int)
ans = 0
n = int(eval(input()))
for _ in range(n):
    s = eval(input())
    lst = [0] * 26
    for c in s:
        idx = ord(c) - base
        lst[idx] += 1
    key = tuple(lst)
    ans += d[key]
    d[key] += 1
print(ans)

from collections import defaultdict

n = int(eval(input()))
d = defaultdict(int)
ans = 0
for _ in range(n):
    s = eval(input())
    s = str(sorted(s))
    ans += d[s]
    d[s] += 1
print(ans)

-base = ord("a") +n = int(eval(input())) -n = int(eval(input())) -    lst = [0] * 26 -    for c in s: -        idx = ord(c) - base -        lst[idx] += 1 -    key = tuple(lst) -    ans += d[key] -    d[key] += 1 +    s = str(sorted(s)) +    ans += d[s] +    d[s] += 1