#include<iostream>
using namespace std;
char o[10] = { };
char p[10] = { };
int n;
int ping = 0;
int jia; int jia1 = 0; int jia2 = 0; int jia3 = 0; int yi1 = 0; int yi2 = 0; int yi3 = 0;
int yi = 0;
void panduan(char a[], char b[]) {
for (int i = 0; i < n; i++) {
if (a[i] == 'C') {
if (b[i] == 'C')
ping++;
else if (b[i] == 'J')
jia1++;//JIA c++
else
yi1++;//YI B++
}
if (a[i] == 'J') {
if (b[i] == 'J')
ping++;
else if (b[i] == 'B')
jia2++;//JIA J++
else
yi2++;//YI C++
}
if (a[i] == 'B') {
if (b[i] == 'B')
ping++;
else if (b[i] == 'C')
jia3++;//JIA B++
else
yi3++;//YI J++
}
}
jia = jia1 + jia2 + jia3;
yi = yi1 + yi2 + yi3;
cout << jia <<' '<< ping <<' '<< yi << endl;
cout << yi <<' '<< ping <<' '<< jia << endl;
int max = jia3;
if (jia2 > max)
max = jia2;
else if (jia1 > max)
max=jia1;
if (max == jia3)
cout << "B ";
else if (max == jia1)
cout << "C ";
else
cout << "J ";
int max2 = yi1;
if (yi2 > max2)
max2 = yi2;
else if (yi3 > max)
max2 = yi3;
if (max2 == yi1)
cout << 'B';
else if (max2 == yi2)
cout << 'C';
else
cout << 'J';
}
int main() {
cin >> n;
char k,z;
for (int i = 0; i < n; i++) {
cin >> k >> z;
o[i] = k;
p[i] = z;
}
panduan(o, p);
for (int i = 0; i < n; i++) {
}
return 0;
}