#include <iostream> using namespace std; int main() { int N; cin>>N; int w1=0,w2=0,w3=0; int ac=0,aj=0,ab=0; int bc=0,bj=0,bb=0; int ra,rb; char a,b; for(int i=0;i<N;i ) { cin>>a>>b; if((a==‘C‘&&b==‘J‘)|| (a==‘J‘&&b==‘B‘)||(a==‘B‘&&b==‘C‘)) { w1 ; if(a==‘C‘) ac ; else if(a==‘J‘) aj ; else ab ; } else if((a==‘C‘&&b==‘C‘)||(a==‘J‘&&b==‘J‘)||(a==‘B‘&&b==‘B‘)) w2 ; else if((a==‘C‘&&b==‘B‘)|| (a==‘J‘&&b==‘C‘)||(a==‘B‘&&b==‘J‘)) { w3 ; if(b==‘C‘) bc ; else if(b==‘J‘) bj ; else bb ; } } cout<<w1<<" "<<w2<<" "<<w3<<endl; cout<<w3<<" "<<w2<<" "<<w1<<endl; ra=ab; rb=bb; char ma,mb; ma=‘B‘; mb=‘B‘; if(ac>ra) { if(aj>ac) { ra=aj; ma=‘J‘; } else { ra=ac; ma=‘C‘; } } else if(aj>ra) { ra=aj; ma=‘J‘; } if(bc>rb) { if(bj>bc) { rb=bj; mb=‘J‘; } else { rb=bc; mb=‘C‘; } } else if(bj>rb) { rb=bj; mb=‘J‘; } cout<<ma<<" "<<mb<<endl; return 0; }