#include <iostream>
using namespace std;

int main() {

    int N, i=0, sumRequired=0, sumA=0, sumB=0, sumAB=0, sumO=0;
    int array[4];
    cin >> N >> array[0] >>  array[1] >> array[2] >> array[3];
    string type[N];
    int units[N];
    for (int j = 0; j < N; j++){
        cin >> type[j] >> units[j];
    }
    
    int sum = array[0] + array[1] + array[2] + array[3];
    for (int j = 0; j < N; j++){
        sumRequired += units[j];
        if(type[j] == "A")
            sumA += units[j];
         else if(type[j] == "B")
            sumB += units[j];
         else if (type[j] == "O")
            sumO += units[j];
         else
            sumAB += units[j];
    }
    if( sum < sumRequired || sumO > array[0] || sumA > (array[0]-sumO + array[1]) || sumB > (array[0]-sumO + array[2]) || ((array[0]-sumO + array[1]) == sumA && sumB > array[2] ) || ((array[0]-sumO + array[2]) == sumB && sumA > array[1] )) {
        cout << "nemoguce";
    }
    else {
        cout << "moguce" << endl;
    }
    
    return 0;
}