#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int o, a, b, ab;
    cin >> o >> a >> b >> ab;
    int naj = max(o, max(a, b));
    int O, A, B, AB;                /// za upis u matricu
    for(int i = 0; i < n; i++){
        string group;
        int unite;
        cin >> group >> unite;
    if(group == "O"){
        if(o < unite){
                cout << "nemoguce";
                break;
        }
        else {
            o -= unite;
            O = unite;
            cout << "moguce"<< endl;
            cout << O << " 0 0 0" << endl;
        }
    }
    if(group == "A"){
        if(a >= unite) {
            a -= unite;
            A = unite;
            cout << "moguce"<< endl;
            cout << "0 " << A << " 0 0" << endl;
        }
        else if(a + o >= unite){
            o = unite - a;
            O = o;
            a = 0;
            A = abs(o - unite);
            cout << "moguce"<< endl;
            cout << O << " " << A << " 0 0" << endl;
        }
        else if(a == 0){
            if(o < unite){
                    cout << "nemoguce";
                    break;
            }
            else {
                o -= unite;
                O = unite;
                cout << "moguce"<< endl;
                cout << O << " 0 0 0"<< endl;
            }
        }
        }
        if(group == "B"){
        if(b >= unite) {
            b -= unite;
            B = unite;
            cout << "moguce"<< endl;
            cout << "0 0 " << B << " 0" << endl;
        }
        else if(b + o >= unite){
            o = unite - b;
            O = o;
            b = 0;
            B = abs(o - unite);
            cout << "moguce"<< endl;
            cout << O << " 0 " << B << " 0" << endl;
        }
        else if(b == 0){
            if(o < unite){
                    cout << "nemoguce";
                    break;
            }
            else {
                o -= unite;
                O = unite;
                cout << "moguce"<< endl;
                cout << O << " 0 0 0"<< endl;
            }
        }
        }
        if(group == "AB"){
            if(ab >= unite){
                ab -= unite;
                AB = unite;
                cout << "moguce"<< endl;
                cout << "0 0 0 "<< AB;
                }
            else if(a > b && a + ab >= unite){
            a = unite - ab;
            A = a;
            ab = 0;
            AB = abs(a - unite);
            cout << "moguce"<< endl;
            cout << "0 "<< A << " 0 " << AB;
            }
            else if(b > a && b + ab >= unite){
            b = unite - ab;
            B = b;
            ab = 0;
            AB = abs(b - unite);
            cout << "moguce"<< endl;
            cout << "0 0 "<< B << " " << AB;
            }
            else if(a + b + ab >= unite && b > a){ /// a je vece od b
            int m = unite - (b + ab);
            b = unite - (a + ab);
            a = m;
            B = b;
            A = abs((ab + b)- unite);
            AB = abs((b + a)- unite);
            ab = 0;
            cout << "moguce" << endl;
            cout << "0 "<< A << " " << B << " " << AB;
            }
            else if(a + b + ab >= unite && a > b){  /// b je vece od a
            int n = unite - (a + ab);
            a = unite - (b + ab);
            b = n;
            A = a;
            B = abs((ab + a)- unite);
            AB = abs((b + a)- unite);
            ab = 0;
            cout << "moguce"<< endl;
            cout << "0 "<< A <<" " << B << " "<< AB;
            }
            else if(ab + a + b + o >= unite){
            o = unite - (ab + a + b);
            O = o;
            A = abs((ab + b + o)- unite);
            B = abs((ab + a + o)- unite);
            AB = abs((o + a + b) - unite);
            a = 0;
            b = 0;
            ab = 0;
            cout << "moguce"<< endl;
            cout << O << " "<< A << " " << B << " " << AB;
            }
            else if((o + a + b)< unite){
                    cout << "nemoguce";
                    break;
            }
            }
        }

    return 0;
    }