#include <bits/stdc++.h>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define ll long long
#define MOD (ll)(1e9+7)
#define MAX (ll)(1e5*2+200)
#define print(x) cout << x << endl;
using namespace std;
ll fac[MAX], mmi[MAX], tmp[MAX];

inline ll pow_mod(ll x, ll n){
    ll ans = 1;
    for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
    if(n&1)ans*=x;
    return ans;
}

inline void factorial(ll A){
    fac[0] = fac[1] = 1;
    for(ll i = 2; i < A; fac[i]%=MOD,i++)
    fac[i] = fac[i-1]*(i%MOD);
}

inline void modular_multiplicatibe_inverse(ll N){
    mmi[N-1] = pow_mod(fac[N-1],MOD-2);
    for(ll i = N-2; i >= 0; mmi[i]%=MOD,i--)
    mmi[i] = mmi[i+1]*(i+1);
}

inline ll comb(ll n, ll r){
    return fac[n]*(mmi[r]*mmi[n-r]%MOD)%MOD;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<string, int> m{};
    string str;
    char Arr[10];
    
    REP(i, N){
        cin >> str;
        REP(i, 10){
            Arr[i] = str[i];
        }
        SORT(Arr, 10);
        str = "";
        REP(i, 10){
            str += Arr[i];
        }
        m[str] += 1;
    }
    int ans = 0;
    factorial(1000);
    modular_multiplicatibe_inverse(1000);
    for (const auto& [key, value] : m){
        ans += comb(value, 2);
    }
    print(ans);
    return 0;
}
