#include <bits/stdc++.h>
using namespace std;
int n;
int a,b,ab,o;
int a1[100005];
int b1[100005];
int ab1[100005];
int o1[100005];
int br=0;
string krv;
int x;
int main(){
    cin>>n;
    cin>>o>>a>>b>>ab;
    for(int i=1;i<=n;i++){
        cin>>krv>>x;
        if(krv=="O"){
            if(x<=o){
            o=o-x;
            o1[i]=x;
            }
        else br=1;}

        if(krv=="A"){
            if(x<=a){
            a=a-x;
            a1[i]=x;
            }
            else if(x<=o+a){
                a1[i]=a;
                o1[i]=x-a;
                o=o-(x-a);
                a=0;
            }
            else if(x<=o){
                o=o-x;
                o1[i]=x;
            }
            else br=1;
            }

        if(krv=="B"){
            if(x<=b){
                b=b-x;
                b1[i]=x;
            }
            else if(x<=b+a){
                b1[i]=b;
                o1[i]=x-b;
                o=o-(x-b);
                b=0;
            }
            else if(x<=o){
                o=o-x;
                o1[i]=x;
            }
            else br=1;
            }


        }

    if(br==1)cout<<"nemoguce"<<endl;
    else{
        cout<<"moguce"<<endl;
        for(int i=1;i<=4;i++){
            cout<<o1[i]<<" "<<a1[i]<<" "<<b1[i]<<" "<<ab1[i]<<endl;
        }
    }


return 0;
}