#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 10010;
long long niz[MAXN];
long long res[MAXN][5];
char s[MAXN][3];
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);
	long long n, o, a, b, ab;
	cin >> n >> o >> a >> b >> ab;
	for(int i = 0; i < n; i++)
		cin >> s[i] >> niz[i];
	for(int i = 0; i < n; i++){
		if(s[i][0] == 'O'){
			o -= niz[i];
			res[i][0] = niz[i];
			res[i][1] = 0; res[i][2] = 0; res[i][3] = 0;
		}
	}
	for(int i = 0; i < n; i++){
		if(s[i][0] == 'A' && s[i][1] != 'B'){
			long long moze = a - niz[i];
			if(moze >= 0){
				a -= niz[i];
				res[i][1] = niz[i];
				res[i][0] = 0; res[i][2] = 0; res[i][3] = 0;
			}
			else{
				res[i][1] = a;
				a = 0;
				o -= abs(moze);
				res[i][0] = abs(moze);
				res[i][2] = 0; res[i][3] = 0;
			}
		}
		else if(s[i][0] == 'B'){
			long long moze = b - niz[i];
			if(moze >= 0){
				b -= niz[i];
				res[i][2] = niz[i];
				res[i][0] = 0; res[i][1] = 0; res[i][3] = 0;
			}
			else{
				res[i][2] = b;
				b = 0;
				o -= abs(moze);
				res[i][0] = abs(moze);
				res[i][1] = 0; res[i][3] = 0;
			}
		}
	}
	for(int i = 0; i < n; i++){
		if(s[i][0] == 'A' && s[i][1] == 'B'){
			if(o > 0 && niz[i] > 0){
				long long moze = o - niz[i];
				if(moze >= 0){
					o -= niz[i];
					res[i][0] = niz[i];
					niz[i] = 0;
				}
				else{
					res[i][0] = o;
					niz[i] -= o;
					o = 0;
				}
			}
			if(a > 0 && niz[i] > 0){
				long long moze = a - niz[i];
				if(moze >= 0){
					a -= niz[i];
					res[i][1] = niz[i];
					niz[i] = 0;
				}
				else{
					res[i][1] = a;
					niz[i] -= a;
					a = 0;
				}
			}
			if(b > 0 && niz[i] > 0){
				long long moze = b - niz[i];
				if(moze >= 0){
					b -= niz[i];
					res[i][2] = niz[i];
					niz[i] = 0;
				}
				else{
					res[i][2] = b;
					niz[i] -= b;
					b = 0;
				}
			}
			if(niz[i] > 0){
				res[i][3] = niz[i];
				ab -= niz[i];
			}
		}
	}
	if(o >= 0 && a >= 0 && b >= 0 && ab >= 0){
		cout << "moguce" << endl;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < 4; j++){
					cout << res[i][j] << " ";
			}
			cout << endl;
		}
	}
	else
		cout << "nemoguce" << endl;

	return 0;
}