from collections import Counter

from math import factorial





def nc2(n):

    return factorial(n) // 2 // factorial(n - 2)





N = int(eval(input()))

counter = Counter()



for _ in range(N):

    s = eval(input())

    counter[''.join(sorted(s))] += 1



print((sum([nc2(count) for count in list(counter.values()) if count > 1])))

from collections import Counter





def nc2(n):

    return n * (n - 1) // 2





N = int(eval(input()))

counter = Counter()



for _ in range(N):

    s = eval(input())

    counter[''.join(sorted(s))] += 1



print((sum([nc2(count) for count in list(counter.values()) if count > 1])))

from collections import Counter
from math import factorial


def nc2(n):
    return factorial(n) // 2 // factorial(n - 2)


N = int(eval(input()))
counter = Counter()
for _ in range(N):
    s = eval(input())
    counter["".join(sorted(s))] += 1
print((sum([nc2(count) for count in list(counter.values()) if count > 1])))

from collections import Counter


def nc2(n):
    return n * (n - 1) // 2


N = int(eval(input()))
counter = Counter()
for _ in range(N):
    s = eval(input())
    counter["".join(sorted(s))] += 1
print((sum([nc2(count) for count in list(counter.values()) if count > 1])))

-from math import factorial -    return factorial(n) // 2 // factorial(n - 2) +    return n * (n - 1) // 2