#include<bits/stdc++.h> using namespace std; int n,how[10010],who[10010][10009],sum; string s[10010][5]; int main(){ cin>>n; for(int i=1;i<=n;i++) for(int j=1;j<=4;j++) cin>>s[i][j]; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i!=j){ if(s[i][1]==s[j][1]||s[i][1]==s[j][2]) who[i][++how[i]]=j; if(s[i][2]==s[j][1]||s[i][2]==s[j][2]) who[i][++how[i]]=j; } } } for(int i=1;i<=n;i++){ for(int j=1;j<=how[i];j++) cout<<who[i][j]<<endl; cout<<endl; } cout<<sum; return 0; }