#include <bits/stdc++.h>
#define sp " "
#define en '\n'

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
    int N;
    cin >> N;
    vector <int> am (4);
    for (int i = 0; i < 4; i++)
        cin >> am[i];
    vector <string> s (N);
    vector <int> a (N);
    for (int i = 0; i < N; i++)
        cin >> s[i] >> a[i];
    int ans [N] [4];
    bool moguce = true;
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < N; j++)
        {
            vector <int> el (4,0);
            vector <bool> moze (4,false);
            bool spada = false;
            if (i == 0 && s[j] == "O")
            {
                spada = true;
                moze[0] = true;
            }
            else if (i == 1 && s[j] == "A")
            {
                spada = true;
                for (int k = 0; k < 2; k++)
                    moze[k] = true;
            }
            else if (i == 2 && s[j] == "B")
            {
                spada = true;
                for (int k = 0; k < 4; k += 2)
                    moze[k] = true;
            }
            else if (i == 3 && s[j] == "AB")
            {
                spada = true;
                for (int k = 0; k < 4; k++)
                    moze[k] = true;
            }
            if (spada)
            {
                int sum = 0;
                for (int k = 3; k >= 0; k--)
                {
                    if (moze[k])
                    {
                        el[k] = a[j] - sum;
                        am[k] -= el[k];
                        if (am[k] < 0 && k != 0)
                        {
                            el[k] += am[k];
                            am[k] = 0;
                        }
                        else if (am[k] < 0)
                            moguce = false;
                        sum += el[k];
                    }
                }
                for (int k = 0; k < 4; k++)
                    ans[j][k] = el[k];
            }
        }
    }
    if (moguce)
    {
        cout << "moguce" << en;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < 4; j++)
                cout << ans[i][j] << sp;
            cout << en;
        }
    }
    else
        cout << "nemoguce";
    return 0;
}