#include<bits/stdc++.h>
using namespace std;
int n,o,a,b,ab,y[1000005];
string x[1000005];
int main(){
    cin>>n>>o>>a>>b>>ab;
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
        if(x[i]=="O" and y[i]<=o){
            o-=y[i];
        }
        else if(x[i]=="O" and y[i]>o){
            cout<<"nemoguce";
            return 0;
        }
    }
    for(int i=1;i<=n;i++){
        if(x[i]=="A" and y[i]<=a){
            a-=y[i];
        }
        else if(x[i]=="A" and y[i]>a and y[i]<=o){
            a-=a;
            o-=(y[i]-a);
        }
        else if(x[i]=="A" and y[i]>a+o){
            cout<<"nemoguce";
            return 0;
        }
    }
    for(int i=1;i<=n;i++){
        if(x[i]=="B" and y[i]<=b){
            b-=y[i];
        }
        else if(x[i]=="B" and y[i]>b and y[i]<=o){
            b-=b;
            o-=(y[i]-b);
        }
        else if(x[i]=="B" and y[i]>b+o){
            cout<<"nemoguce";
            return 0;
        }
    }
    for(int i=1;i<=n;i++){
        if(x[i]=="AB" and y[i]<ab){
            ab-=y[i];
        }
        else if(x[i]=="AB" and y[i]<=o){
            o-=y[i];
        }
        else if(x[i]=="AB" and y[i]<=a){
            a-=y[i];
        }
        else if(x[i]=="AB" and y[i]<=b){
            b-=y[i];
        }
        else if(x[i]=="AB" and y[i]>ab and y[i]>o and y[i]<=(ab+o)){
            ab-=ab;
            o-=y[i]-ab;
        }
        else if(x[i]=="AB" and y[i]>ab and y[i]>a and y[i]<=(ab+a)){
            ab-=ab;
            a-=y[i]-ab;
        }
        else if(x[i]=="AB" and y[i]>ab and y[i]>b and y[i]<=(ab+b)){
            ab-=ab;
            b-=y[i]-ab;
        }
        else if(x[i]=="AB" and y[i]>ab and y[i]>o and y[i]>a and y[i]<=(ab+o+a)){
            ab-=ab;
            o-=o;
            a-=y[i]-ab-o;
        }
        else if(x[i]=="AB" and y[i]>ab and y[i]>o and y[i]>b and y[i]<=(ab+o+b)){
            ab-=ab;
            o-=o;
            b-=y[i]-ab-o;
        }
        else if(x[i]=="AB" and y[i]>ab and y[i]>a and y[i]>b and y[i]<=(ab+b+a)){
            ab-=ab;
            a-=a;
            b-=y[i]-ab-a;
        }
        else if(x[i]=="AB" and y[i]>ab and y[i]>o and y[i]>a and y[i]>b and y[i]<=(ab+a+b+o)){
            ab-=ab;
            o-=o;
            a-=a;
            b-=y[i]-ab-o-a;
        }
        else if(x[i]=="AB" and y[i]>(o+a+b+ab)){
            cout<<"nemoguce";
            return 0;
        }
    }
    cout<<"moguce"<<endl;
return 0;
}