def solve(string):

    n, *ss = string.split()

    d = {}

    for s in ["".join(sorted(x)) for x in ss]:

        d[s] = 1 + d[s] if s in list(d.keys()) else 1

    return str(sum([v * (v - 1) // 2 for v in list(d.values())]))





if __name__ == '__main__':

    n = int(eval(input()))

    print((solve('{}\n'.format(n) + '\n'.join([eval(input()) for _ in range(n)]))))

from collections import Counter





def solve(string):

    n, *ss = string.split()

    d = Counter(s for s in ["".join(sorted(x)) for x in ss])

    return str(sum([v * (v - 1) // 2 for v in list(d.values())]))





if __name__ == '__main__':

    n = int(eval(input()))

    print((solve('{}\n'.format(n) + '\n'.join([eval(input()) for _ in range(n)]))))

def solve(string):
    n, *ss = string.split()
    d = {}
    for s in ["".join(sorted(x)) for x in ss]:
        d[s] = 1 + d[s] if s in list(d.keys()) else 1
    return str(sum([v * (v - 1) // 2 for v in list(d.values())]))


if __name__ == "__main__":
    n = int(eval(input()))
    print((solve("{}\n".format(n) + "\n".join([eval(input()) for _ in range(n)]))))

from collections import Counter


def solve(string):
    n, *ss = string.split()
    d = Counter(s for s in ["".join(sorted(x)) for x in ss])
    return str(sum([v * (v - 1) // 2 for v in list(d.values())]))


if __name__ == "__main__":
    n = int(eval(input()))
    print((solve("{}\n".format(n) + "\n".join([eval(input()) for _ in range(n)]))))

+from collections import Counter + + -    d = {} -    for s in ["".join(sorted(x)) for x in ss]: -        d[s] = 1 + d[s] if s in list(d.keys()) else 1 +    d = Counter(s for s in ["".join(sorted(x)) for x in ss])