#include <iostream>
#include <string>
struct dato{
  int o1;
  int a1;
  int b1;
  int ab1;
};
using namespace std;
int main() {
  int n,o,a,b,ab,nkg;
  string kg,c;
  cin>>n;
  struct dato d[n];
  cin>>o>>a>>b>>ab;
  for(int i=0;i<n;i++){
    cin>>kg>>nkg;
    if(kg=="o" && o>=nkg){
      o-=nkg;
      d[i].o1=nkg;
      d[i].a1=0;
      d[i].b1=0;
      d[i].ab1=0;
      c="moguce";
    }
    else if(kg=="a" && o+a>=nkg){
      if(nkg>a){
        d[i].a1=a;
        d[i].o1=nkg-a;
        a=0;
        o-=d[i].o1; 
      }
      else{
      d[i].o1=0;
      d[i].a1=a-nkg;
      a-=nkg;
      }
      d[i].b1=0;
      d[i].ab1=0;
      c="moguce";
    }
    else if(kg=="b" && o+b>=nkg){
      if(nkg>b){
        d[i].b1=b;
        d[i].o1=nkg-b;
        b=0;
        o-=d[i].o1; 
      }
      else{
      d[i].o1=0;
      d[i].b1=b-nkg;
      b-=nkg;
      }
      d[i].a1=0;
      d[i].ab1=0;
      c="moguce";
    }
    else if(kg=="ab" && o+a+b+ab>=nkg){
      if(ab>=nkg){
        d[i].o1=0;
        d[i].a1=0;
        d[i].b1=0;
        d[i].ab1=nkg;
      }
      else{
        d[i].ab1=ab;
        if(a>=nkg-ab){
          d[i].a1=a-nkg+ab;
          d[i].o1=0;
          a-=d[i].a1;
          d[i].b1=0;
        }
        if(b>=nkg-ab-a){
          d[i].b1=b-nkg+ab+a;
          d[i].o1=0;
          b-=d[i].b1;
        }
        if(b>=nkg-ab-a-b){
          d[i].o1=o-nkg+ab+a+b;
          b-=d[i].o1;
        }
      }
      c="moguce";
    }
    else{
      c="nemoguce";
    }
  }
  cout<<c<<endl;
  if(c=="moguce"){
  for(int i=0;i<n;i++){
    cout<<d[i].o1<<" "<<d[i].a1<<" "<<d[i].b1<<" "<<d[i].ab1<<endl;
  }
  }

}