wa = [0, 0, 1]

for i in range(2, 100005):

    wa.append(wa[-1]+i)



# print(wa)

# exit()



N = int(eval(input()))



# data = set()

data = {}



ans = 0

for i in range(N):

    s_list = list(str(eval(input())))

    s_list = sorted(s_list)

    hoge = "".join(s_list)

    data.setdefault(hoge, 0)

    data[hoge] += 1



for v in list(data.values()):

    ans += wa[v]



print(ans)

def dns(n):

    fact = [0, 0, 1]

    for i in range(2, n+1):

        fact.append(fact[-1]+i)

    return fact





N = int(eval(input()))

S = [eval(input()) for _ in range(N)]



hoge = dns(100008)



anagram_dict = {}



new_S = []



for s in S:

    tmp = "".join(sorted(list(s)))

    new_S.append(tmp)



for s in new_S:

    anagram_dict.setdefault(s, 0)

    anagram_dict[s] += 1



ans = 0

for v in list(anagram_dict.values()):

    ans += hoge[v]



print(ans)

wa = [0, 0, 1]
for i in range(2, 100005):
    wa.append(wa[-1] + i)
# print(wa)
# exit()
N = int(eval(input()))
# data = set()
data = {}
ans = 0
for i in range(N):
    s_list = list(str(eval(input())))
    s_list = sorted(s_list)
    hoge = "".join(s_list)
    data.setdefault(hoge, 0)
    data[hoge] += 1
for v in list(data.values()):
    ans += wa[v]
print(ans)

def dns(n):
    fact = [0, 0, 1]
    for i in range(2, n + 1):
        fact.append(fact[-1] + i)
    return fact


N = int(eval(input()))
S = [eval(input()) for _ in range(N)]
hoge = dns(100008)
anagram_dict = {}
new_S = []
for s in S:
    tmp = "".join(sorted(list(s)))
    new_S.append(tmp)
for s in new_S:
    anagram_dict.setdefault(s, 0)
    anagram_dict[s] += 1
ans = 0
for v in list(anagram_dict.values()):
    ans += hoge[v]
print(ans)

-wa = [0, 0, 1] -for i in range(2, 100005): -    wa.append(wa[-1] + i) -# print(wa) -# exit() +def dns(n): +    fact = [0, 0, 1] +    for i in range(2, n + 1): +        fact.append(fact[-1] + i) +    return fact + + -# data = set() -data = {} +S = [eval(input()) for _ in range(N)] +hoge = dns(100008) +anagram_dict = {} +new_S = [] +for s in S: +    tmp = "".join(sorted(list(s))) +    new_S.append(tmp) +for s in new_S: +    anagram_dict.setdefault(s, 0) +    anagram_dict[s] += 1 -for i in range(N): -    s_list = list(str(eval(input()))) -    s_list = sorted(s_list) -    hoge = "".join(s_list) -    data.setdefault(hoge, 0) -    data[hoge] += 1 -for v in list(data.values()): -    ans += wa[v] +for v in list(anagram_dict.values()): +    ans += hoge[v]