#include <bits/stdc++.h>
using namespace std;

void finish() {
    cout << "nemoguce" << endl;
    exit(0);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, o, a, b, ab;
    cin >> n >> o >> a >> b >> ab;
    vector<vector<int>> ans(n, {-1});
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        int x; cin >> x; c[i] = x;
        if (s == "O") {
            if (x > o) {
                finish();
            }
            ans[i] = {x, 0, 0, 0};
            o -= x;
        }
        else if (s == "A") {
            if (o + a < x) {
                finish();
            }
            int z = min(a, x);
            ans[i] = {x - z, z, 0, 0};
            o -= (x - z); a -= z;
        }
        else if (s == "B") {
            if (o + b < x) {
                finish();
            }
            int z = min(b, x);
            ans[i] = {x - z, 0, z, 0};
            o -= (x - z); b -= z;
        }
    }
    for (int i = 0; i < n; i++) {
        if (ans[i][0] != -1) {
            continue;
        }
        int x = c[i], z;
        ans[i] = {0, 0, 0, 0};
        z = min(o, x); ans[i][0] = z;
        o -= z; x -= z;
        z = min(a, x); ans[i][1] = z;
        a -= z; x -= z;
        z = min(b, x); ans[i][2] = z;
        b -= z; x -= z;
        z = min(ab, x); ans[i][3] = z;
        ab -= z; x -= z;
        if (x) {
            finish();
        }
    }
    cout << "moguce" << endl;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 4; j++) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}