#include <string>
#include <vector>
#include <map>
using namespace std;
string FindType(map<char,int>& table) {
string answer = "";
if(table['R'] >= table['T']) answer += "R";
else answer += "T";
if(table['C'] >= table['F']) answer += "C";
else answer += "F";
if(table['J'] >= table['M']) answer += "J";
else answer += "M";
if(table['A'] >= table['N']) answer += "A";
else answer += "N";
return answer;
}
string solution(vector<string> survey, vector<int> choices) {
map<char, int> table;
for(int idx = 0; idx < choices.size(); idx++) {
if(choices.at(idx) < 4) {
table[survey[idx][0]] = table[survey[idx][0]] + (4 - choices[idx]);
} else if (choices.at(idx) > 4){
table[survey[idx][1]] = table[survey[idx][1]] + (choices[idx] - 4);
}
}
string answer = FindType(table);
return answer;
}