#include <iostream>
#include <string.h>

using namespace std;


int main()
{
    int N;
    cin >> N;

    int numO,numA,numB,numAB;
    cin >> numO;
    cin >> numA;
    cin >> numB;
    cin >> numAB;
    int potO = 0;
    int potA = 0;
    int potB = 0;
    string arr[N];
    for (int i=0;i<N;i++){
        getline(cin >> ws, arr[i]);
    }
    for (int i=0;i<N;i++){
        string temp = arr[i];
        int pos = temp.find(" ");
        string strlet = temp.substr(0,pos);
        string strnum = temp.substr(pos);
        int tempnum = stoi(strnum);
        if (strlet == "A"){
            potA += tempnum;
        }
        else if(strlet == "B"){
            potB += tempnum;
        }
        else if (strlet == "O"){
            potO += tempnum;
        }
    }
    if (potO > numO || potA > numA + (numO-potO)){
        cout << "nemoguce" << endl;
    }else{
        cout << "moguce" << endl;
        for (int i=0;i<N;i++){
        string temp = arr[i];
        int pos = temp.find(" ");
        string strlet = temp.substr(0,pos);
        string strnum = temp.substr(pos);
        int tempnum = stoi(strnum);
        if (strlet == "A"){
            int temp2 = 0;
            if (numA >= tempnum){
                numA -= tempnum;
                cout << temp2 << " " << tempnum << " " << 0 << " " << 0 << endl;
            }else{
                temp2 = tempnum - numA;
                cout << temp2 << " " << numA << " " << 0 << " " << 0 << endl;
                numA -= tempnum - numA;
                numO -= temp2;
            }
        }
        if (strlet == "B"){
            int temp2 = 0;
            if (numB >= tempnum){
                numB -= tempnum;
                cout << temp2 << " " << tempnum << " " << 0 << " " << 0 << endl;
            }else{
                temp2 = tempnum - numB;
                cout << temp2 << " " << numB << " " << 0 << " " << 0 << endl;
                numB -= tempnum - numB;
                numO -= temp2;
            }
        }
        else if (strlet == "O"){
            cout << tempnum << " " << 0 << " " << 0 << " " << 0 << endl;
        }
    }
    }

}