import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    static int N;
    static HashMap<String, Long> m;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();

        scanner.nextLine();

        long cnt = 0;
        m = new HashMap<>();
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            ArrayList<Character> list = new ArrayList<>();
            for(int j = 0; j < 10; j++) {
                list.add(line.charAt(j));
            }
            Collections.sort(list);
            StringBuilder sb = new StringBuilder();
            for(Character c: list) {
                sb.append(c);
            }
            String srt = sb.toString();
            if(m.containsKey(srt)) {
                cnt += m.get(srt);
                m.put(srt, m.get(srt) + 1);
            } else {
                m.put(srt, (long) 1);
            }
        }

        System.out.println(cnt);
        scanner.close();
    }


    public static void main(String args[]) {
        init();
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util public class Main {
    static int N;
    static HashMap<String, Long> m;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();

        scanner.nextLine();

        long cnt = 0;
        m = new HashMap<>();
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            ArrayList<Character> list = new ArrayList<>();
            for(int j = 0; j < 10; j++) {
                list.add(line.charAt(j));
            }
            Collections.sort(list);
            StringBuilder sb = new StringBuilder();
            for(Character c: list) {
                sb.append(c);
            }
            String srt = sb.toString();
            if(m.containsKey(srt)) {
                cnt += m.get(srt);
                m.put(srt, m.get(srt) + 1);
            } else {
                m.put(srt, (long) 1);
            }
        }

        System.out.println(cnt);
        scanner.close();
    }


    public static void main(String args[]) {
        init();
    }
} Main static int N; N static HashMap<String, Long> m; m private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();

        scanner.nextLine();

        long cnt = 0;
        m = new HashMap<>();
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            ArrayList<Character> list = new ArrayList<>();
            for(int j = 0; j < 10; j++) {
                list.add(line.charAt(j));
            }
            Collections.sort(list);
            StringBuilder sb = new StringBuilder();
            for(Character c: list) {
                sb.append(c);
            }
            String srt = sb.toString();
            if(m.containsKey(srt)) {
                cnt += m.get(srt);
                m.put(srt, m.get(srt) + 1);
            } else {
                m.put(srt, (long) 1);
            }
        }

        System.out.println(cnt);
        scanner.close();
    } init {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();

        scanner.nextLine();

        long cnt = 0;
        m = new HashMap<>();
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            ArrayList<Character> list = new ArrayList<>();
            for(int j = 0; j < 10; j++) {
                list.add(line.charAt(j));
            }
            Collections.sort(list);
            StringBuilder sb = new StringBuilder();
            for(Character c: list) {
                sb.append(c);
            }
            String srt = sb.toString();
            if(m.containsKey(srt)) {
                cnt += m.get(srt);
                m.put(srt, m.get(srt) + 1);
            } else {
                m.put(srt, (long) 1);
            }
        }

        System.out.println(cnt);
        scanner.close();
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) N = scanner.nextInt() N scanner.nextInt() scanner.nextInt scanner scanner.nextLine() scanner.nextLine scanner long cnt = 0; cnt 0 m = new HashMap<>() m new HashMap<>() for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            ArrayList<Character> list = new ArrayList<>();
            for(int j = 0; j < 10; j++) {
                list.add(line.charAt(j));
            }
            Collections.sort(list);
            StringBuilder sb = new StringBuilder();
            for(Character c: list) {
                sb.append(c);
            }
            String srt = sb.toString();
            if(m.containsKey(srt)) {
                cnt += m.get(srt);
                m.put(srt, m.get(srt) + 1);
            } else {
                m.put(srt, (long) 1);
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            String line = scanner.nextLine();
            ArrayList<Character> list = new ArrayList<>();
            for(int j = 0; j < 10; j++) {
                list.add(line.charAt(j));
            }
            Collections.sort(list);
            StringBuilder sb = new StringBuilder();
            for(Character c: list) {
                sb.append(c);
            }
            String srt = sb.toString();
            if(m.containsKey(srt)) {
                cnt += m.get(srt);
                m.put(srt, m.get(srt) + 1);
            } else {
                m.put(srt, (long) 1);
            }
        } {
            String line = scanner.nextLine();
            ArrayList<Character> list = new ArrayList<>();
            for(int j = 0; j < 10; j++) {
                list.add(line.charAt(j));
            }
            Collections.sort(list);
            StringBuilder sb = new StringBuilder();
            for(Character c: list) {
                sb.append(c);
            }
            String srt = sb.toString();
            if(m.containsKey(srt)) {
                cnt += m.get(srt);
                m.put(srt, m.get(srt) + 1);
            } else {
                m.put(srt, (long) 1);
            }
        } String line = scanner.nextLine(); line scanner.nextLine() scanner.nextLine scanner ArrayList<Character> list = new ArrayList<>(); list new ArrayList<>() for(int j = 0; j < 10; j++) {
                list.add(line.charAt(j));
            } int j = 0; int j = 0; j 0 j < 10 j 10 j++ j++ j {
                list.add(line.charAt(j));
            } {
                list.add(line.charAt(j));
            } list.add(line.charAt(j)) list.add list line.charAt(j) line.charAt line j Collections.sort(list) Collections.sort Collections list StringBuilder sb = new StringBuilder(); sb new StringBuilder() for(Character c: list) {
                sb.append(c);
            } Character c list {
                sb.append(c);
            } {
                sb.append(c);
            } sb.append(c) sb.append sb c String srt = sb.toString(); srt sb.toString() sb.toString sb if(m.containsKey(srt)) {
                cnt += m.get(srt);
                m.put(srt, m.get(srt) + 1);
            } else {
                m.put(srt, (long) 1);
            } m.containsKey(srt) m.containsKey m srt {
                cnt += m.get(srt);
                m.put(srt, m.get(srt) + 1);
            } cnt += m.get(srt) cnt m.get(srt) m.get m srt m.put(srt, m.get(srt) + 1) m.put m srt m.get(srt) + 1 m.get(srt) m.get m srt 1 {
                m.put(srt, (long) 1);
            } m.put(srt, (long) 1) m.put m srt (long) 1 System.out.println(cnt) System.out.println System.out System System.out cnt scanner.close() scanner.close scanner public static void main(String args[]) {
        init();
    } main {
        init();
    } init() init String args[] args public class Main {
    static int N;
    static HashMap<String, Long> m;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();

        scanner.nextLine();

        long cnt = 0;
        m = new HashMap<>();
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            ArrayList<Character> list = new ArrayList<>();
            for(int j = 0; j < 10; j++) {
                list.add(line.charAt(j));
            }
            Collections.sort(list);
            StringBuilder sb = new StringBuilder();
            for(Character c: list) {
                sb.append(c);
            }
            String srt = sb.toString();
            if(m.containsKey(srt)) {
                cnt += m.get(srt);
                m.put(srt, m.get(srt) + 1);
            } else {
                m.put(srt, (long) 1);
            }
        }

        System.out.println(cnt);
        scanner.close();
    }


    public static void main(String args[]) {
        init();
    }
} public class Main {
    static int N;
    static HashMap<String, Long> m;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();

        scanner.nextLine();

        long cnt = 0;
        m = new HashMap<>();
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            ArrayList<Character> list = new ArrayList<>();
            for(int j = 0; j < 10; j++) {
                list.add(line.charAt(j));
            }
            Collections.sort(list);
            StringBuilder sb = new StringBuilder();
            for(Character c: list) {
                sb.append(c);
            }
            String srt = sb.toString();
            if(m.containsKey(srt)) {
                cnt += m.get(srt);
                m.put(srt, m.get(srt) + 1);
            } else {
                m.put(srt, (long) 1);
            }
        }

        System.out.println(cnt);
        scanner.close();
    }


    public static void main(String args[]) {
        init();
    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    static int N;
    static HashMap<String, Long> m;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();

        scanner.nextLine();

        long cnt = 0;
        m = new HashMap<>();
        for(int i = 0; i < N; i++) {
            String line = scanner.nextLine();
            ArrayList<Character> list = new ArrayList<>();
            for(int j = 0; j < 10; j++) {
                list.add(line.charAt(j));
            }
            Collections.sort(list);
            StringBuilder sb = new StringBuilder();
            for(Character c: list) {
                sb.append(c);
            }
            String srt = sb.toString();
            if(m.containsKey(srt)) {
                cnt += m.get(srt);
                m.put(srt, m.get(srt) + 1);
            } else {
                m.put(srt, (long) 1);
            }
        }

        System.out.println(cnt);
        scanner.close();
    }


    public static void main(String args[]) {
        init();
    }
}
