#include<bits/stdc++.h>

using namespace std;

int main(){
    int n, o, a, b, ab;
    cin>>n>>o>>a>>b>>ab;
    int ro = 0;
    int ra = 0;
    int rb = 0;
    int rab = 0;
    vector<string> v1;
    vector<int> v2;
    for(int i = 0;i<n;i++){
        string s;
        int g;
        cin>>s>>g;
        if(s=="O"){
            ro+=g;
        }
        if(s=="A"){
            ra+=g;
        }
        if(s=="B"){
            rb+=g;
        }
        if(s=="AB"){
            rab+=g;
        }
        v1.push_back(s);
        v2.push_back(g);
    }
    if(((o+a)<(ro+ra))||(o<ro)||((o+b)<(ro+rb))||((ab+o-ro+a-ra+b-rb)<rab)){
        cout<<"nemoguce"<<endl;
        return 0;
    } else{
        cout<<"moguce"<<endl;
    }



    return 0;
}