N=int(eval(input()))

d=dict()

ans=0

for _ in range(N):

  s=eval(input())

  s=tuple(sorted(s))

  if s in d:

    d[s]+=1

  else:

    d[s]=0

for i in list(d.values()):

  ans+=(int(i)**2+int(i))/2

print((int(ans)))
def f(n):

  return (n**2-n)//2

ans=0

N=int(eval(input()))

d=dict()

for i in range(N):

  s="".join(sorted(eval(input())))

  if s not in d:

    d[s]=0

  d[s]+=1

for i in d:

  ans+=f(d[i])

print(ans)

N = int(eval(input()))
d = dict()
ans = 0
for _ in range(N):
    s = eval(input())
    s = tuple(sorted(s))
    if s in d:
        d[s] += 1
    else:
        d[s] = 0
for i in list(d.values()):
    ans += (int(i) ** 2 + int(i)) / 2
print((int(ans)))

def f(n):
    return (n**2 - n) // 2


ans = 0
N = int(eval(input()))
d = dict()
for i in range(N):
    s = "".join(sorted(eval(input())))
    if s not in d:
        d[s] = 0
    d[s] += 1
for i in d:
    ans += f(d[i])
print(ans)

+def f(n): +    return (n**2 - n) // 2 + + +ans = 0 -ans = 0 -for _ in range(N): -    s = eval(input()) -    s = tuple(sorted(s)) -    if s in d: -        d[s] += 1 -    else: +for i in range(N): +    s = "".join(sorted(eval(input()))) +    if s not in d: -for i in list(d.values()): -    ans += (int(i) ** 2 + int(i)) / 2 -print((int(ans))) +    d[s] += 1 +for i in d: +    ans += f(d[i]) +print(ans)