#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int o,a,b,ab;
    cin>>o>>a>>b>>ab;
    vector<tuple<int,int,int,int> > v(n);
    vector<pair<int,int> > abindeksi;
    bool moze=true;
    for(int i=0;i<n;i++)
    {
        string tip;
        cin>>tip;
        int koliko;
        cin>>koliko;
        if(tip=="O")
        {
            if(koliko>o)  moze=false;
            else
            {
                v[i]=make_tuple(koliko,0,0,0);
                o-=koliko;
            }
        }
        else if(tip=="A")
        {
            if(koliko>o+a) moze=false;
            else
            {
                if(a>=koliko)
                {
                    a-=koliko;
                    v[i]=make_tuple(0,koliko,0,0);
                }
                else
                {
                    v[i]=make_tuple(koliko-a,a,0,0);
                    o-=(koliko-a);
                    a=0;
                }
            }
        }
        else if(tip=="B")
        {
            if(koliko>o+b) moze=false;
            else
            {
                if(b>=koliko)
                {
                    b-=koliko;
                    v[i]=make_tuple(0,0,koliko,0);
                }
                else
                {
                    v[i]=make_tuple(koliko-b,0,b,0);
                    o-=(koliko-b);
                    b=0;
                }
            }
        }
        else
        {
            abindeksi.push_back(make_pair(i,koliko));
        }
    }
    for(int i=0;i<(int)abindeksi.size();i++)
    {
        if(o>=abindeksi[i].second)
        {
            v[abindeksi[i].first]=make_tuple(abindeksi[i].second,0,0,0);
            o-=abindeksi[i].second;
        }
        else if(o+a>=abindeksi[i].second)
        {
            v[abindeksi[i].first]=make_tuple(o,abindeksi[i].second-o,0,0);
            o=0;
            a-=(abindeksi[i].second-o);
        }
        else if(o+a+b>=abindeksi[i].second)
        {
            v[abindeksi[i].first]=make_tuple(o,a,abindeksi[i].second-o-a,0);
            o=0;
            a=0;
            b-=(abindeksi[i].second-o-a);
        }
        else if(o+a+b+ab>=abindeksi[i].second)
        {
            v[abindeksi[i].first]=make_tuple(o,a,b,abindeksi[i].second-o-a-b);
            o=0;
            a=0;
            b=0;
            ab-=(abindeksi[i].second-o-a-b);
        }
        else return cout<<"nemoguce"<<endl,0;
    }
    if(!moze) return cout<<"nemoguce"<<endl,0;
    cout<<"moguce"<<endl;
    for(int i=0;i<n;i++)
    {
        cout<<get<0>(v[i])<<" "<<get<1>(v[i])<<" "<<get<2>(v[i])<<" "<<get<3>(v[i])<<endl;
    }
    return 0;

}