#include<bits/stdc++.h> using namespace std; string u[10000]; int o=0; int f[10005][10005]; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ string u1,u2,u3,u4; cin>>u1>>u2>>u3>>u4; int x1=0,x2=0; for(int j=1;j<=o;j++){ if(u[j]==u1){ x1=j; } if(u[j]==u4){ x2=j; } } if(x1==0){ o++; u[o]=u1; x1=o; } if(x2==0){ o++; u[o]=u4; x2=o; } f[x1][x2]++; } int ans=0; for(int u1=1;u1<=o;u1++){ for(int u2=1;u2<=o;u2++){ for(int u3=1;u3<=o;u3++){ for(int u4=1;u4<=o;u4++){ ans+=f[u1][u2]*f[u2][u3]*f[u3][u4]*f[u4][u1]*f[u1][u3]*f[u2][u4]; } } } } cout<<ans; return 0; }