import collections

 

N = int(eval(input()))

Sum = 0

lists = []

for i in range(N):

    s = str(eval(input()))

    s_list = list(s)

    s_list.sort()

    m = "".join(s_list)

    lists.append(m)

c = collections.Counter(lists)

set_lists = list(set(lists))

for i in range(len(set_lists)):

    n = c[str(set_lists[i])]

    Sum += n * (n - 1) // 2

lists.sort()

print(Sum)
import collections

def nCr(n, r):

    """

    Calculate the number of combination (nCr = nPr/r!).

    The parameters need to meet the condition of n >= r >= 0.

    It returns 1 if r == 0, which means there is one pattern

    to choice 0 items out of the number of n.

    """

 

    # 10C7 = 10C3

    r = min(r, n-r)

 

    # Calculate the numerator.

    numerator = 1

    for i in range(n, n-r, -1):

        numerator *= i

 

    # Calculate the denominator. Should use math.factorial?

    denominator = 1

    for i in range(r, 1, -1):

        denominator *= i

 

    return numerator // denominator

 

N = int(eval(input()))

Sum = 0

lists = []

for i in range(N):

    s = str(eval(input()))

    s_list = list(s)

    s_list.sort()

    m = "".join(s_list)

    lists.append(m)

c = collections.Counter(lists)

set_lists = list(set(lists))

for i in range(len(set_lists)):

    cnt = c[str(set_lists[i])]

    if cnt == 1:

        pass

    else:

        Sum += nCr(cnt,2)

print(Sum)
import collections

N = int(eval(input()))
Sum = 0
lists = []
for i in range(N):
    s = str(eval(input()))
    s_list = list(s)
    s_list.sort()
    m = "".join(s_list)
    lists.append(m)
c = collections.Counter(lists)
set_lists = list(set(lists))
for i in range(len(set_lists)):
    n = c[str(set_lists[i])]
    Sum += n * (n - 1) // 2
lists.sort()
print(Sum)

import collections


def nCr(n, r):
    """
    Calculate the number of combination (nCr = nPr/r!).
    The parameters need to meet the condition of n >= r >= 0.
    It returns 1 if r == 0, which means there is one pattern
    to choice 0 items out of the number of n.
    """
    # 10C7 = 10C3
    r = min(r, n - r)
    # Calculate the numerator.
    numerator = 1
    for i in range(n, n - r, -1):
        numerator *= i
    # Calculate the denominator. Should use math.factorial?
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i
    return numerator // denominator


N = int(eval(input()))
Sum = 0
lists = []
for i in range(N):
    s = str(eval(input()))
    s_list = list(s)
    s_list.sort()
    m = "".join(s_list)
    lists.append(m)
c = collections.Counter(lists)
set_lists = list(set(lists))
for i in range(len(set_lists)):
    cnt = c[str(set_lists[i])]
    if cnt == 1:
        pass
    else:
        Sum += nCr(cnt, 2)
print(Sum)

+ + +def nCr(n, r): +    """ +    Calculate the number of combination (nCr = nPr/r!). +    The parameters need to meet the condition of n >= r >= 0. +    It returns 1 if r == 0, which means there is one pattern +    to choice 0 items out of the number of n. +    """ +    # 10C7 = 10C3 +    r = min(r, n - r) +    # Calculate the numerator. +    numerator = 1 +    for i in range(n, n - r, -1): +        numerator *= i +    # Calculate the denominator. Should use math.factorial? +    denominator = 1 +    for i in range(r, 1, -1): +        denominator *= i +    return numerator // denominator + -    n = c[str(set_lists[i])] -    Sum += n * (n - 1) // 2 -lists.sort() +    cnt = c[str(set_lists[i])] +    if cnt == 1: +        pass +    else: +        Sum += nCr(cnt, 2)