# coding: utf-8

n = int(eval(input()))

dic = {}

for i in range(n):

    t = ''.join(sorted(eval(input())))

    dic.setdefault(t, 0)

    dic[t] += 1

ans = 0

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

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

print(ans)
# coding: utf-8

n = int(eval(input()))

dic = {}

for i in range(n):

    s = "".join(sorted(eval(input())))

    dic.setdefault(s, 0)

    dic[s] += 1

ans = 0

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

    ans += int(x * (x - 1) / 2)

print(ans)
# coding: utf-8
n = int(eval(input()))
dic = {}
for i in range(n):
    t = "".join(sorted(eval(input())))
    dic.setdefault(t, 0)
    dic[t] += 1
ans = 0
for x in list(dic.values()):
    ans += x * (x - 1) // 2
print(ans)

# coding: utf-8
n = int(eval(input()))
dic = {}
for i in range(n):
    s = "".join(sorted(eval(input())))
    dic.setdefault(s, 0)
    dic[s] += 1
ans = 0
for x in list(dic.values()):
    ans += int(x * (x - 1) / 2)
print(ans)

-    t = "".join(sorted(eval(input()))) -    dic.setdefault(t, 0) -    dic[t] += 1 +    s = "".join(sorted(eval(input()))) +    dic.setdefault(s, 0) +    dic[s] += 1 -    ans += x * (x - 1) // 2 +    ans += int(x * (x - 1) / 2)