#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    int N;
    char O,A,B,AB;
    char x[100];
    cin>>N;
    cin>>O>>A>>B>>AB;
    for(int i=0;i<N;i++)
    {
        cin>>x[i];
    }
    int br=0,br2=0,br3=0,br4=0;
    for(int i=0;i<N;i++)
    {
        if(strcmp(x[i]=="O" && O>0))
            br++;
        if(x[i]=="A" && O>0 || A>0)
            br2++;
        if(x[i]=="B" && O>0 || B>0)
            br3++;
        if(x[i]=="AB" && O>0 || A>0 || B>0 || AB>0)
            br4++;

    }
    if(br>0,br2>0,br3>0,br4>0)
        cout<<"moze"<<endl;
        for(int i;i<N;i++)
        {
            cout<<br<<br2<<br3<<br4<<endl;
        }
    else
        cout<<"nemoguce"<<endl;
    return 0;
}