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

int main(){
	int n,o,a,b,ab;
	cin >> n >> o >> a >> b >> ab;
	char c[n];
	int j[n],oj[n],aj[n],bj[n];
	for (int i = 0; i < n; i++){
		cin >> c[i] >> j[i];
	}
	if (ab > 0){
		cout << "nemoguce";
		return 0;
	}
	for (int i = 0; i < n; i++){
		if (c[i] == 'O'){
			oj[i] = j[i];
			aj[i] = 0;
			bj[i] = 0;
			o = o - j[i];
			if (o < 0){
				cout << "nemoguce";
				return 0;
			}
		}
		else if (c[i] == 'A'){
			bj[i] = 0;
			if (a - j[i] >= 0){
				aj[i] = j[i];
				a = a - j[i];
				oj[i] = 0;
			}
			else if (a > 0){
				aj[i] = a;
				a = 0;
				oj[i] = j[i] - aj[i];
				o = o - oj[i];
				if (o < 0){
				cout << "nemoguce";
				return 0;
			}
			}
			else {
				aj[i] = 0;
				oj[i] = j[i];
				o = o - oj[i];
				if (o < 0){
				cout << "nemoguce";
				return 0;
			}
			}
		}
		else {
			aj[i] = 0;
			if (b - j[i] >= 0){
				bj[i] = j[i];
				b = b - j[i];
				oj[i] = 0;
			}
			else if (b > 0){
				bj[i] = b;
				b = 0;
				oj[i] = j[i] - bj[i];
				o = o - oj[i];
				if (o < 0){
				cout << "nemoguce";
				return 0;
			}
			}
			else {
				bj[i] = 0;
				oj[i] = j[i];
				o = o - oj[i];
				if (o < 0){
				cout << "nemoguce";
				return 0;
			}
			}
		}
	}
	cout << "moguce" << endl;
	for (int i = 0; i < n; i++){
		cout << oj[i] << " " << aj[i] << " " << bj[i] << " "<< 0 << endl;
	}
}