from collections import Counter,defaultdict



N=int(eval(input()))

count = defaultdict(int)

for i in range(N):

  s=Counter(list(eval(input())))

  count[str(sorted(s.items()))] += 1



count = list(count.values())

SUM = 0

for c in count:

  if c>1:SUM += c*(c-1)//2

print(SUM)
from collections import defaultdict



N=int(eval(input()))

count = defaultdict(int)

for i in range(N):

  s = eval(input())

  s = ''.join(sorted(s))

  count[s] += 1



SUM = 0

for val in list(count.values()):

  if val > 1:SUM+=val*(val-1)//2

print(SUM)
from collections import Counter, defaultdict

N = int(eval(input()))
count = defaultdict(int)
for i in range(N):
    s = Counter(list(eval(input())))
    count[str(sorted(s.items()))] += 1
count = list(count.values())
SUM = 0
for c in count:
    if c > 1:
        SUM += c * (c - 1) // 2
print(SUM)

from collections import defaultdict

N = int(eval(input()))
count = defaultdict(int)
for i in range(N):
    s = eval(input())
    s = "".join(sorted(s))
    count[s] += 1
SUM = 0
for val in list(count.values()):
    if val > 1:
        SUM += val * (val - 1) // 2
print(SUM)

-from collections import Counter, defaultdict +from collections import defaultdict -    s = Counter(list(eval(input()))) -    count[str(sorted(s.items()))] += 1 -count = list(count.values()) +    s = eval(input()) +    s = "".join(sorted(s)) +    count[s] += 1 -for c in count: -    if c > 1: -        SUM += c * (c - 1) // 2 +for val in list(count.values()): +    if val > 1: +        SUM += val * (val - 1) // 2