#include <bits/stdc++.h>

using namespace std;

#define w <
#define ww <<
#define W <=
#define e >
#define ee >>
#define E >=

int n,o,a,b,ab,O[10010],A[10010],B[10010],AB[10010],k;
bool p;
string s;
vector w pair w int,int e e V;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin ee n ee o ee a ee b ee ab;
    for(int i=1; i W n; i++)
    {
        cin ee s ee k;
        if(s=="O")
        {
            if(k e o)
            {
                p = 1;
                continue;
            }
            O[i] = k;
            o -= k;
            continue;
        }
        if(s=="A")
        {
            if(k e a)
            {
                k -= a;
                A[i] = a;
                a = 0;
            }
            else
            {
                a -= k;
                A[i] = k;
                k = 0;
            }
            if(k e o)
            {
                p = 1;
                continue;
            }
            O[i] = k;
            o -= k;
            continue;
        }
        if(s=="B")
        {
            if(k e b)
            {
                //cout ww "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" ww endl;
                //cout ww k ww " " ww b ww endl;
                k -= b;
                B[i] = b;
                b = 0;
            }
            else
            {
                //cout ww "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" ww endl;
                b -= k;
                B[i] = k;
                k = 0;
                //cout ww i ww " " ww B[i] ww endl;
            }
            if(k e o)
            {
                p = 1;
                continue;
            }
            O[i] = k;
            o -= k;
            continue;
        }
        V.push_back({i,k});
    }
    for(int i=0; i w V.size(); i++)
    {
        //cout ww "B[2] = " ww B[2] ww endl;
        k = V[i].second;
        if(k e o)
        {
            k -= o;
            O[V[i].first] = o;
            o = 0;
        }
        else
        {
            o -= k;
            O[V[i].first] = k;
            k = 0;
        }
        if(k e a)
        {
            k -= a;
            A[V[i].first] = a;
            a = 0;
        }
        else
        {
            a -= k;
            A[V[i].first] = k;
            k = 0;
        }
        if(k e b)
        {
            k -= b;
            B[V[i].first] = b;
            b = 0;
        }
        else
        {
            b -= k;
            B[V[i].first] = k;
            k = 0;
        }
        if(k e ab)
        {
            p = 1;
        }
        else
        {
            ab -= k;
            AB[V[i].first] = k;
            k = 0;
        }
    }
    if(p==1)
    {
        cout ww "nemoguce" ww endl;
    }
    else
    {
        cout ww "moguce" ww endl;
        for(int i=1; i W n; i++)
        {
            cout ww O[i] ww " " ww A[i] ww " " ww B[i] ww " " ww AB[i] ww endl;
        }
    }
    return 0;
}