#include <bits/stdc++.h>
using namespace std;
int N,O,A,brO=0,brA=0,br1A=0,sljt=0,zbir=0;
char a[1002];
int p[1003];
int main(){
  cin >> N;
  cin >> O >> A ;
  for(int i=1;i<=N;i++){
    cin >> a[i];
    cin >> p[i];
    if(a[i]=='O'){sljt+=p[i];}
    zbir+=p[i];
  }
  for(int j=1;j<=N;j++){
    if(a[j]=='O'){
      if(p[j]<=O){
        O-=p[j];
        brO=p[j];
      }
    }
    else if(a[j]=='A'){
     if(p[j]<=A){
        brA=p[j];
        A-=p[j];
     }
     else if(p[j]<=O+A){
        int x=p[j];
        brA+=A;
        br1A+=p[j]-brA;
     }
    }
  }
 if(O>=sljt and O+A>=zbir ){
  cout << "nemoguce"<<endl;
 }
 else {cout << "moguce"<<endl;
  for(int z=1;z<=N;z++){
    if(a[z]=='O'){
        cout << brO <<" "<< 0<<" "<< 0<<" "<< 0 <<endl;
    }
    else if(a[z]=='A'){cout << br1A <<" "<< brA<<" "<< 0<<" "<< 0 <<endl;}
  }}
 return 0;
}