#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<pair<char,int> >v(n);
	int o,a,b,ab;
	cin>>o>>a>>b>>ab;
	int ou=0,au=0,bu=0,abu=0;
	for(int i=0;i<n;i++){
		cin>>v[i].first>>v[i].second;
		if(v[i].first=='O') ou+=v[i].second;
		if(v[i].first=='A') au+=v[i].second;
	}
	if((o-ou)<0){
		cout<<"nemoguce";
		return 0;
	}
	else if(((o-ou)+a<au)){
		cout<<"nemoguce";
		return 0;
	}
	cout<<"moguce"<<endl;
	int po=0,pa=0,pb=0,pab=0;
	for(int i=0;i<n;i++){
		if(v[i].first=='O'){
			po=v[i].second;
			o=o-po;
			pa=0;
			cout<<po<<" "<<pa<<" "<<pb<<" "<<pab<<endl;
		}
		if(v[i].first=='A'){
			if(v[i].second<=a){
				po=0;
				pa=v[i].second;
				a=a-pa;
			    cout<<po<<" "<<pa<<" "<<pb<<" "<<pab<<endl;
			}
			else{
				pa=a;
				a=0;
				po=v[i].second-pa;
				o=o-po;
				cout<<po<<" "<<pa<<" "<<pb<<" "<<pab<<endl;
			}
		}
	}
	return 0;
}