import java.util.*;

public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        long ans = 0;

        //input
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        String s[]=new String[n];
        Map<List<String>,Long> map = new HashMap<>();
        for (int i=0;i<n;++i)
        {
            s[i]=sc.next();
            List<String> stringList = new ArrayList<>();
            for (int j=0;j<10;++j)
            {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            }

            Collections.sort(stringList);
            //System.out.println(Arrays.toString(stringList.toArray()));

            if (map.containsKey(stringList))
            {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            }else
            {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            }
        }

        for (List<String> list:map.keySet())
        {
            //System.out.println("key ="+Arrays.toString(list.toArray())+" value = "+map.get(list));
            long b=map.get(list);

            long c=0;
            while (true)
            {
                --b;
                if (b==0)break;
                c+=b;
            }
            ans+=c;
        }

        System.out.println(ans);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        long ans = 0;

        //input
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        String s[]=new String[n];
        Map<List<String>,Long> map = new HashMap<>();
        for (int i=0;i<n;++i)
        {
            s[i]=sc.next();
            List<String> stringList = new ArrayList<>();
            for (int j=0;j<10;++j)
            {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            }

            Collections.sort(stringList);
            //System.out.println(Arrays.toString(stringList.toArray()));

            if (map.containsKey(stringList))
            {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            }else
            {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            }
        }

        for (List<String> list:map.keySet())
        {
            //System.out.println("key ="+Arrays.toString(list.toArray())+" value = "+map.get(list));
            long b=map.get(list);

            long c=0;
            while (true)
            {
                --b;
                if (b==0)break;
                c+=b;
            }
            ans+=c;
        }

        System.out.println(ans);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
} Main public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        long ans = 0;

        //input
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        String s[]=new String[n];
        Map<List<String>,Long> map = new HashMap<>();
        for (int i=0;i<n;++i)
        {
            s[i]=sc.next();
            List<String> stringList = new ArrayList<>();
            for (int j=0;j<10;++j)
            {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            }

            Collections.sort(stringList);
            //System.out.println(Arrays.toString(stringList.toArray()));

            if (map.containsKey(stringList))
            {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            }else
            {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            }
        }

        for (List<String> list:map.keySet())
        {
            //System.out.println("key ="+Arrays.toString(list.toArray())+" value = "+map.get(list));
            long b=map.get(list);

            long c=0;
            while (true)
            {
                --b;
                if (b==0)break;
                c+=b;
            }
            ans+=c;
        }

        System.out.println(ans);
        //output
        //System.out.println(String.format("%.0f",answer));
    } main {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        long ans = 0;

        //input
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        String s[]=new String[n];
        Map<List<String>,Long> map = new HashMap<>();
        for (int i=0;i<n;++i)
        {
            s[i]=sc.next();
            List<String> stringList = new ArrayList<>();
            for (int j=0;j<10;++j)
            {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            }

            Collections.sort(stringList);
            //System.out.println(Arrays.toString(stringList.toArray()));

            if (map.containsKey(stringList))
            {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            }else
            {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            }
        }

        for (List<String> list:map.keySet())
        {
            //System.out.println("key ="+Arrays.toString(list.toArray())+" value = "+map.get(list));
            long b=map.get(list);

            long c=0;
            while (true)
            {
                --b;
                if (b==0)break;
                c+=b;
            }
            ans+=c;
        }

        System.out.println(ans);
        //output
        //System.out.println(String.format("%.0f",answer));
    } int count = 0; count 0 boolean sw = false; sw false int max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE double dMax = Double.MIN_VALUE; dMax Double.MIN_VALUE Double Double.MIN_VALUE double dMin = Double.MAX_VALUE; dMin Double.MAX_VALUE Double Double.MAX_VALUE long ans = 0; ans 0 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n =sc.nextInt(); n sc.nextInt() sc.nextInt sc String s[]=new String[n]; s new String[n] n Map<List<String>,Long> map = new HashMap<>(); map new HashMap<>() for (int i=0;i<n;++i)
        {
            s[i]=sc.next();
            List<String> stringList = new ArrayList<>();
            for (int j=0;j<10;++j)
            {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            }

            Collections.sort(stringList);
            //System.out.println(Arrays.toString(stringList.toArray()));

            if (map.containsKey(stringList))
            {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            }else
            {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            }
        } int i=0; int i=0; i 0 i<n i n ++i ++i i {
            s[i]=sc.next();
            List<String> stringList = new ArrayList<>();
            for (int j=0;j<10;++j)
            {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            }

            Collections.sort(stringList);
            //System.out.println(Arrays.toString(stringList.toArray()));

            if (map.containsKey(stringList))
            {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            }else
            {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            }
        } {
            s[i]=sc.next();
            List<String> stringList = new ArrayList<>();
            for (int j=0;j<10;++j)
            {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            }

            Collections.sort(stringList);
            //System.out.println(Arrays.toString(stringList.toArray()));

            if (map.containsKey(stringList))
            {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            }else
            {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            }
        } s[i]=sc.next() s[i] s i sc.next() sc.next sc List<String> stringList = new ArrayList<>(); stringList new ArrayList<>() for (int j=0;j<10;++j)
            {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            } int j=0; int j=0; j 0 j<10 j 10 ++j ++j j {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            } {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            } String ss=s[i].substring(j,j+1); ss s[i].substring(j,j+1) s[i].substring s[i] s i j j+1 j 1 stringList.add(ss) stringList.add stringList ss Collections.sort(stringList) Collections.sort Collections stringList if (map.containsKey(stringList))
            {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            }else
            {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            } map.containsKey(stringList) map.containsKey map stringList {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            } long a=map.get(stringList); a map.get(stringList) map.get map stringList ++a a map.put(stringList,a) map.put map stringList a {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            } long a=1; a 1 map.put(stringList,a) map.put map stringList a for (List<String> list:map.keySet())
        {
            //System.out.println("key ="+Arrays.toString(list.toArray())+" value = "+map.get(list));
            long b=map.get(list);

            long c=0;
            while (true)
            {
                --b;
                if (b==0)break;
                c+=b;
            }
            ans+=c;
        } List<String> list map.keySet() map.keySet map {
            //System.out.println("key ="+Arrays.toString(list.toArray())+" value = "+map.get(list));
            long b=map.get(list);

            long c=0;
            while (true)
            {
                --b;
                if (b==0)break;
                c+=b;
            }
            ans+=c;
        } {
            //System.out.println("key ="+Arrays.toString(list.toArray())+" value = "+map.get(list));
            long b=map.get(list);

            long c=0;
            while (true)
            {
                --b;
                if (b==0)break;
                c+=b;
            }
            ans+=c;
        } long b=map.get(list); b map.get(list) map.get map list long c=0; c 0 while (true)
            {
                --b;
                if (b==0)break;
                c+=b;
            } true {
                --b;
                if (b==0)break;
                c+=b;
            } --b b if (b==0)break; b==0 b 0 break; c+=b c b ans+=c ans c System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        long ans = 0;

        //input
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        String s[]=new String[n];
        Map<List<String>,Long> map = new HashMap<>();
        for (int i=0;i<n;++i)
        {
            s[i]=sc.next();
            List<String> stringList = new ArrayList<>();
            for (int j=0;j<10;++j)
            {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            }

            Collections.sort(stringList);
            //System.out.println(Arrays.toString(stringList.toArray()));

            if (map.containsKey(stringList))
            {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            }else
            {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            }
        }

        for (List<String> list:map.keySet())
        {
            //System.out.println("key ="+Arrays.toString(list.toArray())+" value = "+map.get(list));
            long b=map.get(list);

            long c=0;
            while (true)
            {
                --b;
                if (b==0)break;
                c+=b;
            }
            ans+=c;
        }

        System.out.println(ans);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
} public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        long ans = 0;

        //input
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        String s[]=new String[n];
        Map<List<String>,Long> map = new HashMap<>();
        for (int i=0;i<n;++i)
        {
            s[i]=sc.next();
            List<String> stringList = new ArrayList<>();
            for (int j=0;j<10;++j)
            {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            }

            Collections.sort(stringList);
            //System.out.println(Arrays.toString(stringList.toArray()));

            if (map.containsKey(stringList))
            {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            }else
            {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            }
        }

        for (List<String> list:map.keySet())
        {
            //System.out.println("key ="+Arrays.toString(list.toArray())+" value = "+map.get(list));
            long b=map.get(list);

            long c=0;
            while (true)
            {
                --b;
                if (b==0)break;
                c+=b;
            }
            ans+=c;
        }

        System.out.println(ans);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();
        long ans = 0;

        //input
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        String s[]=new String[n];
        Map<List<String>,Long> map = new HashMap<>();
        for (int i=0;i<n;++i)
        {
            s[i]=sc.next();
            List<String> stringList = new ArrayList<>();
            for (int j=0;j<10;++j)
            {
                String ss=s[i].substring(j,j+1);
                stringList.add(ss);
            }

            Collections.sort(stringList);
            //System.out.println(Arrays.toString(stringList.toArray()));

            if (map.containsKey(stringList))
            {
                long a=map.get(stringList);
                ++a;
                //System.out.println(stringList);
                map.put(stringList,a);
            }else
            {
                //System.out.println(stringList);
                long a=1;
                map.put(stringList,a);
            }
        }

        for (List<String> list:map.keySet())
        {
            //System.out.println("key ="+Arrays.toString(list.toArray())+" value = "+map.get(list));
            long b=map.get(list);

            long c=0;
            while (true)
            {
                --b;
                if (b==0)break;
                c+=b;
            }
            ans+=c;
        }

        System.out.println(ans);
        //output
        //System.out.println(String.format("%.0f",answer));
    }
}