#include <iostream>
#include <string>
using namespace std;
int main()
{
	
	bool nemoguce=false;
	int n;
	cin >>n;
	int mat[n][4];
	int o,a,b,ab;
	cin>>o>>a>>b>>ab;
	for (int i=0;i<n;i++)
	{
		int dn=0,da=0,db=0,dab=0;
		string s;
		int broj;
		cin >>s >>broj;
		if(s=="A" && !nemoguce)
		{
			da=broj;
			if(broj<a)
			{
				a=a-broj;
				mat[i][0]=dn;
				mat[i][1]=da;
				mat[i][2]=db;
				mat[i][3]=dab;
			}
			else
			{
				da=broj-a;
				broj=broj-a;
				goto x;
			}
		}
		else if(s=="B" && !nemoguce)
		{
			db=broj;
			if(broj<b)
			{
				b=b-broj;
				mat[i][0]=dn;
				mat[i][1]=da;
				mat[i][2]=db;
				mat[i][3]=dab;
			}
			else
			{
				db=broj-b;
				broj=broj-b;
				goto x;
			}
		}
		else if(s=="AB" && !nemoguce)
		{
			nemoguce=true;
		}
		else
		{
			x:if(!nemoguce)
			{
				dn=broj;
				if(broj>o) nemoguce=true;
				else
				{
					
					o=o-broj;
					mat[i][0]=dn;
					mat[i][1]=da;
					mat[i][2]=db;
					mat[i][3]=dab;
				}
			}
			
		}
	}
	if(nemoguce) cout<<"nemoguce";
	else{
		cout<<"moguce"<<endl;
		for (int i =0;i<n;i++)
		{
			for(int j = 0; j<4; j++)
				cout<<mat[i][j]<<" ";
			cout<<endl;
		}
	}
	return 0;
}