#include<bits/stdc++.h>
using namespace std;
int O,A,B,AB,n,o,a,b,ab,m[10005],ko,ka,kb,kab;
bool l;
string s[10005];
int main()
{
  cin>>n>>O>>A>>B>>AB;
  for(int i=0;i<n;i++){
    cin>>s[i]>>m[i];
    if(s[i]=="O")o++;
    else if(s[i]=="A")a++;
    else if(s[i]=="B")b++;
    else if(s[i]=="AB")ab++;
  }
  l=false;
  ko=O;
  ka=A;
  kb=B;
  kab=AB;
  if(O-o>=0){
    O-=o;
    if(A>=a){
      A-=a;
      if(B>=b){
        B-=b;
        if(AB>=ab){
          cout<<"moguce"<<endl;
          l=true;
        }
        else if(O+A+B+AB>=ab){
          cout<<"moguce"<<endl;
        }
      }
      else if(B+O>=b){
        b-=B;
        O-=b;
        if(AB>=ab){
          cout<<"moguce"<<endl;
          l=true;
        }
        else if(O+A+B+AB>=ab){
          cout<<"moguce"<<endl;
        }
      }
    }
    else if(A+O>=a){
      a-=A;
      O-=a;
      if(B>=b){
        B-=b;
        if(AB>=ab){
          cout<<"moguce"<<endl;
          l=true;
        }
        else if(O+A+B+AB>=ab){
          cout<<"moguce"<<endl;
        }
      }
      else if(B+O>=b){
        b-=B;
        O-=b;
        if(AB>=ab){
          cout<<"moguce"<<endl;
          l=true;
        }
        else if(O+A+B+AB>=ab){
          cout<<"moguce"<<endl;
        }
      }
    }
  }
  O=ko;
  A=ka;
  B=kb;
  AB=kab;
  if(l==true){
    for(int j=0;j<n;j++){

    }
  }
  else cout<<"nemoguce"<<endl;
  return 0;
}