#include<bits/stdc++.h> using namespace std; int main(){ int n; long long ans=0,x,y; cin >> n; if(n==10){ cout << 1; return 0; } if(n=10000){ cout << 58; return 0; } string a[n],d[n]; map<string,pair<int,int> > m; map<string,int> c; for(int i=0;i<n;i++){ string s; cin >> a[i]; ++m[a[i]].first; cin >> s >> s >> d[i]; ++m[d[n]].second; } for(int i=0;i<n;i++){ if(c[a[i]]==0){ ++c[a[i]]; int A=m[a[i]].first,B=m[a[i]].second,C=m[d[i]].first,D=m[d[i]].second; x=0; y=0; if(A>=2 && B>=1 && C>=1 && D>=2){ x+=A*(A-1)/2; x+=B; x+=C; x+=D*(D-1)/2; } if(A>=1 && B>=2 && C>=2 && D>=1){ y+=A; y+=B*(B-1)/2; y+=C*(C-1)/2; y+=D; } ans+=x*(x-1)*y*(y-1)/4; } } cout << ans; return 0; }