from collections import defaultdict





def solve(string):

    n, *s = string.split()

    d = defaultdict(int)

    for _s in s:

        d["".join(sorted(_s))] += 1

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





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 ss:

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

        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 defaultdict


def solve(string):
    n, *s = string.split()
    d = defaultdict(int)
    for _s in s:
        d["".join(sorted(_s))] += 1
    return str(sum([v * (v - 1) // 2 for v in list(d.values()) if v > 1]))


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 ss:
        s = "".join(sorted(s))
        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 defaultdict - - -    n, *s = string.split() -    d = defaultdict(int) -    for _s in s: -        d["".join(sorted(_s))] += 1 -    return str(sum([v * (v - 1) // 2 for v in list(d.values()) if v > 1])) +    n, *ss = string.split() +    d = {} +    for s in ss: +        s = "".join(sorted(s)) +        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())]))