【Basic Level】
*1018
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cctype>
#include <vector>
using namespace std;
int main()
{
int n;
cin >> n;
char p1, p2;
int j = 0, k = 0, l = 0;
int a = 0, b = 0, c = 0;
int a1 = 0, b1 = 0, c1 = 0;
while (n--)
{
cin >> p1 >> p2;
if (p1 == p2)
{
++k;
}
else if ((p1 == 'C' && p2 == 'J') || (p1 == 'J' && p2 == 'B') || (p1 == 'B' && p2 == 'C'))
{
++j;
if (p1 == 'C')
{
++a;
}
else if (p1 == 'J')
{
++b;
}
else
{
++c;
}
}
else
{
++l;
if (p2 == 'C')
{
++a1;
}
else if (p2 == 'J')
{
++b1;
}
else
{
++c1;
}
}
}
cout << j << " " << k << " " << l << endl;
cout << l << " " << k << " " << j << endl;
if (c >= a && c >= b)
{
cout << "B ";
}
else if (a > c && a >= b)
{
cout << "C ";
}
else
{
cout << "J ";
}
if (c1 >= a1 && c1 >= b1)
{
cout << "B\n";
}
else if (a1 > c1 && a1 >= b1)
{
cout << "C\n";
}
else
{
cout << "J\n";
}
//system("pause");
return 0;
}