#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
using namespace std;
struct candidates {
string name;
double numb;
};
bool c(candidates x, candidates y)
{
return x.numb > y.numb;
}
int main() {
int candidateNum, ballotNum;
cin >> candidateNum >> ballotNum;
candidates* candidate = new candidates[candidateNum+1];
string s = "";
for (int i = 0; i < candidateNum; i++)
{
cin >> s;
candidate[i].name = s;
candidate[i].numb = 0;
}
candidate[candidateNum].name = "Invalid";
candidate[candidateNum].numb = 0;
int count = 0, num;
for (int i = 0; i < ballotNum; i++)
{
cin >> s;
count = 0;
for (int j = 0; j < candidateNum; j++)
{
if (s[j] == 'X')
{
count++;
num = j;
}
if (isalpha(s[j]) && s[j] != 'X')
count=2;
}
if (count == 1)
{
candidate[num].numb++;
}
else
candidate[candidateNum].numb++;
}
sort(candidate, candidate + candidateNum,c);
for (int i = 0; i <= candidateNum; i++)
{
cout << fixed << setprecision(2) << candidate[i].name << " " << (candidate[i].numb*100)/ballotNum << "%\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8aW9tYW5pcD4KI2luY2x1ZGUgPGFsZ29yaXRobT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cnVjdCBjYW5kaWRhdGVzIHsKCXN0cmluZyBuYW1lOwoJZG91YmxlIG51bWI7Cn07Cgpib29sIGMoY2FuZGlkYXRlcyB4LCBjYW5kaWRhdGVzIHkpCnsKCXJldHVybiB4Lm51bWIgPiB5Lm51bWI7Cn0KCmludCBtYWluKCkgewoJaW50IGNhbmRpZGF0ZU51bSwgYmFsbG90TnVtOwoJY2luID4+IGNhbmRpZGF0ZU51bSA+PiBiYWxsb3ROdW07CgljYW5kaWRhdGVzKiBjYW5kaWRhdGUgPSBuZXcgY2FuZGlkYXRlc1tjYW5kaWRhdGVOdW0rMV07CglzdHJpbmcgcyA9ICIiOwoJZm9yIChpbnQgaSA9IDA7IGkgPCBjYW5kaWRhdGVOdW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