from collections import Counter

N = int(eval(input()))

S = set()

cnt = 0



def createStr(counter):

    ret = ""

    keys = list(counter.keys())

    keys.sort()

    for key in keys:

        ret += key

        ret += str(counter[key])

    return ret



ret = {}

for i in range(N):

    s = Counter(eval(input()))

    s = createStr(s)

    if s in list(ret.keys()):

        ret[s] += 1

    else:

        ret[s] = 1



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

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



print(cnt)

from collections import Counter

N = int(eval(input()))

S = set()

cnt = 0



def createStr(intput_str):

    ret = ""

    intput_str = sorted(intput_str)

    for s in intput_str:

        ret += s

    return ret



ret = {}

for i in range(N):

    s = createStr(eval(input()))

    if s in list(ret.keys()):

        ret[s] += 1

    else:

        ret[s] = 1



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

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



print(cnt)

from collections import Counter

N = int(eval(input()))
S = set()
cnt = 0


def createStr(counter):
    ret = ""
    keys = list(counter.keys())
    keys.sort()
    for key in keys:
        ret += key
        ret += str(counter[key])
    return ret


ret = {}
for i in range(N):
    s = Counter(eval(input()))
    s = createStr(s)
    if s in list(ret.keys()):
        ret[s] += 1
    else:
        ret[s] = 1
for i in list(ret.values()):
    cnt += i * (i - 1) // 2
print(cnt)

from collections import Counter

N = int(eval(input()))
S = set()
cnt = 0


def createStr(intput_str):
    ret = ""
    intput_str = sorted(intput_str)
    for s in intput_str:
        ret += s
    return ret


ret = {}
for i in range(N):
    s = createStr(eval(input()))
    if s in list(ret.keys()):
        ret[s] += 1
    else:
        ret[s] = 1
for i in list(ret.values()):
    cnt += i * (i - 1) // 2
print(cnt)

-def createStr(counter): +def createStr(intput_str): -    keys = list(counter.keys()) -    keys.sort() -    for key in keys: -        ret += key -        ret += str(counter[key]) +    intput_str = sorted(intput_str) +    for s in intput_str: +        ret += s -    s = Counter(eval(input())) -    s = createStr(s) +    s = createStr(eval(input()))