using System;
using System.Text;
using System.Collections.Generic;
public class Solution
{
public string solution(string[] survey, int[] choices)
{
string answer = "";
Dictionary<string, int> result = new Dictionary<string, int>()
{
{ "R", 0 },
{ "T", 0 },
{ "C", 0 },
{ "F", 0 },
{ "J", 0 },
{ "M", 0 },
{ "A", 0 },
{ "N" , 0 }
};
for (int i = 0; i < survey.Length; i++)
{
string type = "";
string s1 = survey[i];
if (choices[i] < 4)
{
type += s1[0];
if (choices[i] == 1) result[type] += 3;
else if (choices[i] == 2) result[type] += 2;
else if (choices[i] == 3) result[type] += 1;
}
else if (choices[i] > 4)
{
type += s1[1];
if (choices[i] == 5) result[type] += 1;
else if (choices[i] == 6) result[type] += 2;
else if (choices[i] == 7) result[type] += 3;
}
}
List<string> s = new List<string>() { "R", "T", "C", "F", "J", "M", "A", "N" };
for (int j = 0; j < s.Count; j += 2)
{
string c1 = s[j];
string c2 = s[j + 1];
if (result[c1] < result[c2]) answer += s[j + 1];
else if (result[c1] > result[c2]) answer += s[j];
else if (result[c1] == result[c2])
{
byte[] b1 = Encoding.ASCII.GetBytes(c1);
byte[] b2 = Encoding.ASCII.GetBytes(c2);
answer += (b1[0] < b2[0]) ? c1 : c2;
}
}
return answer;
}
}