import math

def P(n, r):

    return math.factorial(n)//math.factorial(n-r)

def C(n, r):

    return P(n, r)//math.factorial(r)

def moji(s):

    tmp = []

    for i in range(10):

        tmp.append(s[i])

    tmp.sort()

    new_s = ''

    for i in range(10):

        new_s += tmp[i]

    return new_s



N = int(eval(input()))

dic = {}

ans = 0

for i in range(N):

    tmp = moji(eval(input()))

    if tmp in dic:

        dic[tmp] += 1

    else:

        dic[tmp] = 1

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

    if i == 1:

        continue

    ans += C(i,2)

print(ans)

from collections import defaultdict

import math

def P(n, r):

    return math.factorial(n)//math.factorial(n-r)

def C(n, r):

    if n <= 1:

        return 0

    return P(n, r)//math.factorial(r)

N = int(eval(input()))

d = defaultdict(int)

for i in range(N):

    d[','.join(sorted(eval(input())))] += 1

ans = 0

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

    ans += C(value,2)

print(ans)
import math


def P(n, r):
    return math.factorial(n) // math.factorial(n - r)


def C(n, r):
    return P(n, r) // math.factorial(r)


def moji(s):
    tmp = []
    for i in range(10):
        tmp.append(s[i])
    tmp.sort()
    new_s = ""
    for i in range(10):
        new_s += tmp[i]
    return new_s


N = int(eval(input()))
dic = {}
ans = 0
for i in range(N):
    tmp = moji(eval(input()))
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1
for i in list(dic.values()):
    if i == 1:
        continue
    ans += C(i, 2)
print(ans)

from collections import defaultdict
import math


def P(n, r):
    return math.factorial(n) // math.factorial(n - r)


def C(n, r):
    if n <= 1:
        return 0
    return P(n, r) // math.factorial(r)


N = int(eval(input()))
d = defaultdict(int)
for i in range(N):
    d[",".join(sorted(eval(input())))] += 1
ans = 0
for value in list(d.values()):
    ans += C(value, 2)
print(ans)

+from collections import defaultdict +    if n <= 1: +        return 0 -def moji(s): -    tmp = [] -    for i in range(10): -        tmp.append(s[i]) -    tmp.sort() -    new_s = "" -    for i in range(10): -        new_s += tmp[i] -    return new_s - - -dic = {} +d = defaultdict(int) +for i in range(N): +    d[",".join(sorted(eval(input())))] += 1 -for i in range(N): -    tmp = moji(eval(input())) -    if tmp in dic: -        dic[tmp] += 1 -    else: -        dic[tmp] = 1 -for i in list(dic.values()): -    if i == 1: -        continue -    ans += C(i, 2) +for value in list(d.values()): +    ans += C(value, 2)