def dic(s):

  dics,ans=[],""

  for i in range(len(s)):dics.append(s[i])

  dics.sort()

  for i in dics:ans+=i

  return ans

n=int(eval(input()))

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

s.sort()

a=b=1

c=""

for i in range(n):

  if c!=s[i]:

    b+=a*(a-1)//2

    a=1

    c=s[i]

  else:a+=1

b+=a*(a-1)//2

print((b-1))
n=int(eval(input()))

def f(s):

  return "".join(sorted(list(s)))

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

from collections import Counter

d=Counter(s)

ans=0

for i in d:ans+=d[i]*(d[i]-1)//2

print(ans)
def dic(s):
    dics, ans = [], ""
    for i in range(len(s)):
        dics.append(s[i])
    dics.sort()
    for i in dics:
        ans += i
    return ans


n = int(eval(input()))
s = [dic(eval(input())) for _ in range(n)]
s.sort()
a = b = 1
c = ""
for i in range(n):
    if c != s[i]:
        b += a * (a - 1) // 2
        a = 1
        c = s[i]
    else:
        a += 1
b += a * (a - 1) // 2
print((b - 1))

n = int(eval(input()))


def f(s):
    return "".join(sorted(list(s)))


s = [f(eval(input())) for _ in range(n)]
from collections import Counter

d = Counter(s)
ans = 0
for i in d:
    ans += d[i] * (d[i] - 1) // 2
print(ans)

-def dic(s): -    dics, ans = [], "" -    for i in range(len(s)): -        dics.append(s[i]) -    dics.sort() -    for i in dics: -        ans += i -    return ans +n = int(eval(input())) -n = int(eval(input())) -s = [dic(eval(input())) for _ in range(n)] -s.sort() -a = b = 1 -c = "" -for i in range(n): -    if c != s[i]: -        b += a * (a - 1) // 2 -        a = 1 -        c = s[i] -    else: -        a += 1 -b += a * (a - 1) // 2 -print((b - 1)) +def f(s): +    return "".join(sorted(list(s))) + + +s = [f(eval(input())) for _ in range(n)] +from collections import Counter + +d = Counter(s) +ans = 0 +for i in d: +    ans += d[i] * (d[i] - 1) // 2 +print(ans)