from operator import mul

from functools import reduce



def cmb(n,r):

    if r==0 or n==r:return 1

    r = min(n-r,r)

    ue = reduce(mul, list(range(n, n-r, -1)))

    shita = reduce(mul, list(range(1,r+1)))

    return ue//shita



n=int(eval(input()))

l=[eval(input()) for i in range(n)]

for i in range(n):

	l[i]="".join(sorted(l[i]))

l.sort()

cnt=ans=0

ref=[]

for i,j in zip(l,l[1:]):

	if i==j:

		cnt+=1

	else:

		ref.append(cnt)

		cnt=0

ref.append(cnt)

for i in ref:

	if i!=0:

		ans+=cmb(i+1,2)

print(ans)
from operator import mul

from functools import reduce

from collections import Counter



def cmb(n,r):

	if n < r:return 0

	if r == 0 or n-r == 0:return 1

	r = min(n-r,r)

	up = reduce(mul, list(range(n, n-r, -1)))

	down = reduce(mul, list(range(1,r+1)))

	return up//down

    

l = []

for i in range(int(eval(input()))):

	l.append("".join(sorted(eval(input()))))

c = Counter(l)

ans = 0

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

	ans += cmb(i,2)

print(ans)
from operator import mul
from functools import reduce


def cmb(n, r):
    if r == 0 or n == r:
        return 1
    r = min(n - r, r)
    ue = reduce(mul, list(range(n, n - r, -1)))
    shita = reduce(mul, list(range(1, r + 1)))
    return ue // shita


n = int(eval(input()))
l = [eval(input()) for i in range(n)]
for i in range(n):
    l[i] = "".join(sorted(l[i]))
l.sort()
cnt = ans = 0
ref = []
for i, j in zip(l, l[1:]):
    if i == j:
        cnt += 1
    else:
        ref.append(cnt)
        cnt = 0
ref.append(cnt)
for i in ref:
    if i != 0:
        ans += cmb(i + 1, 2)
print(ans)

from operator import mul
from functools import reduce
from collections import Counter


def cmb(n, r):
    if n < r:
        return 0
    if r == 0 or n - r == 0:
        return 1
    r = min(n - r, r)
    up = reduce(mul, list(range(n, n - r, -1)))
    down = reduce(mul, list(range(1, r + 1)))
    return up // down


l = []
for i in range(int(eval(input()))):
    l.append("".join(sorted(eval(input()))))
c = Counter(l)
ans = 0
for i in list(c.values()):
    ans += cmb(i, 2)
print(ans)

+from collections import Counter -    if r == 0 or n == r: +    if n < r: +        return 0 +    if r == 0 or n - r == 0: -    ue = reduce(mul, list(range(n, n - r, -1))) -    shita = reduce(mul, list(range(1, r + 1))) -    return ue // shita +    up = reduce(mul, list(range(n, n - r, -1))) +    down = reduce(mul, list(range(1, r + 1))) +    return up // down -n = int(eval(input())) -l = [eval(input()) for i in range(n)] -for i in range(n): -    l[i] = "".join(sorted(l[i])) -l.sort() -cnt = ans = 0 -ref = [] -for i, j in zip(l, l[1:]): -    if i == j: -        cnt += 1 -    else: -        ref.append(cnt) -        cnt = 0 -ref.append(cnt) -for i in ref: -    if i != 0: -        ans += cmb(i + 1, 2) +l = [] +for i in range(int(eval(input()))): +    l.append("".join(sorted(eval(input())))) +c = Counter(l) +ans = 0 +for i in list(c.values()): +    ans += cmb(i, 2)