from collections import Counter



N = int(eval(input()))

a=[]

for i in range(N):

    s=eval(input())

    S=[]

    for j in range(10):

        S.append(s[j])

    S.sort()

    s="".join(S).split()

    a.append(s[0])

x=Counter(a)

num=list(x.values())

#print(list(num))

ans=0

for i in (list(num)):

    ans+=i*(i-1)//2

print(ans)

from collections import Counter



N = int(eval(input()))

a=[]

for i in range(N):

    s=eval(input())

    s="".join(sorted(s)).split()

    a.append(s[0])

num=list(Counter(a).values())

#print(list(num))

ans=0

for i in (list(num)):

    ans+=i*(i-1)//2

print(ans)

from collections import Counter

N = int(eval(input()))
a = []
for i in range(N):
    s = eval(input())
    S = []
    for j in range(10):
        S.append(s[j])
    S.sort()
    s = "".join(S).split()
    a.append(s[0])
x = Counter(a)
num = list(x.values())
# print(list(num))
ans = 0
for i in list(num):
    ans += i * (i - 1) // 2
print(ans)

from collections import Counter

N = int(eval(input()))
a = []
for i in range(N):
    s = eval(input())
    s = "".join(sorted(s)).split()
    a.append(s[0])
num = list(Counter(a).values())
# print(list(num))
ans = 0
for i in list(num):
    ans += i * (i - 1) // 2
print(ans)

-    S = [] -    for j in range(10): -        S.append(s[j]) -    S.sort() -    s = "".join(S).split() +    s = "".join(sorted(s)).split() -x = Counter(a) -num = list(x.values()) +num = list(Counter(a).values())