#include<iostream>//剪刀石头布
using namespace std;
int main()
{
int N;
cin >> N;
char** a = new char* [N];
for (int i = 0; i < N; i++)
{
a[i] = new char[2];
}
for (int k = 0; k < N; k++)
{
for (int j = 0; j < 2; j++)
{
cin >> a[k][j];
}
}
int q = 0, b = 0, c = 0, d = 0, e = 0, f = 0,n=0,m=0,p=0;
for (int i = 0; i < N; i++)
{
if (a[i][0] == 'C' && a[i][1] == 'J')
{
q++;
d++;
}
else if (a[i][0] == 'C' && a[i][1] == 'B')
{
b++;
p++;
}
else if (a[i][0] == 'J' && a[i][1] == 'B')
{
q++;
e++;
}
else if (a[i][0] == 'J' && a[i][1] == 'C')
{
b++;
n++;
}
else if (a[i][0] == 'B' && a[i][1] == 'C')
{
q++;
f++;
}
else if (a[i][0] == 'B'&&a[i][1]=='J')
{
b++;
m++;
}
else
{
c++;
}
}
cout << q << " " << c << " " << N - q - c << endl;
cout << b << " " << c << " " << N - c - b << endl;
if (d > e && d > f)
{
cout << "C"<<" ";
}
if (e > d && e > f)
{
cout << "B" << " ";
}
if (f > d && f > e)
{
cout << "F" << " ";
}
if (d < e && e ==f)
{
cout << "B" << " ";
}
if (e < f && d == f)
{
cout << "C" << " ";
}
if (f < d && d == e)
{
cout << "B" << " ";
}
if (d == e && e == f)
{
cout << "B" << " ";
}
if (m> n && m >p)
{
cout << "C" ;
}
if (n > m && n > p)
{
cout << "F" ;
}
if (p > m && p > n)
{
cout << "B";
}
if (m < n && n == p)
{
cout << "B";
}
if (n < p && m == p)
{
cout << "C";
}
if (p < m && m == n)
{
cout << "B";
}
if (m == n && n == p)
{
cout << "B";
}
return 0;
}