import collections

import sys



N = int(eval(input()))

s = [sorted(collections.Counter(sys.stdin.readline().rstrip()).items()) for _ in range(N)]



counted = {}

for s_count in s:

    if str(s_count) not in counted:

        counted[str(s_count)] = 1

    else:

        counted[str(s_count)] += 1





count = 0        

for n in list(counted.values()):

    count += n * (n - 1) // 2

            

print(count)
n = int(eval(input()))

s = [eval(input()) for _ in range(n)]

for i in range(n):

  s[i] = ''.join(sorted(s[i]))

t = {}

for i in range(n):

  if s[i] in t:

    t[s[i]] += 1

  else:

    t[s[i]] = 1

print((sum(t[k] * (t[k] -1) // 2 for k in t)))
import collections
import sys

N = int(eval(input()))
s = [
    sorted(collections.Counter(sys.stdin.readline().rstrip()).items()) for _ in range(N)
]
counted = {}
for s_count in s:
    if str(s_count) not in counted:
        counted[str(s_count)] = 1
    else:
        counted[str(s_count)] += 1
count = 0
for n in list(counted.values()):
    count += n * (n - 1) // 2
print(count)

n = int(eval(input()))
s = [eval(input()) for _ in range(n)]
for i in range(n):
    s[i] = "".join(sorted(s[i]))
t = {}
for i in range(n):
    if s[i] in t:
        t[s[i]] += 1
    else:
        t[s[i]] = 1
print((sum(t[k] * (t[k] - 1) // 2 for k in t)))

-import collections -import sys - -N = int(eval(input())) -s = [ -    sorted(collections.Counter(sys.stdin.readline().rstrip()).items()) for _ in range(N) -] -counted = {} -for s_count in s: -    if str(s_count) not in counted: -        counted[str(s_count)] = 1 +n = int(eval(input())) +s = [eval(input()) for _ in range(n)] +for i in range(n): +    s[i] = "".join(sorted(s[i])) +t = {} +for i in range(n): +    if s[i] in t: +        t[s[i]] += 1 -        counted[str(s_count)] += 1 -count = 0 -for n in list(counted.values()): -    count += n * (n - 1) // 2 -print(count) +        t[s[i]] = 1 +print((sum(t[k] * (t[k] - 1) // 2 for k in t)))