#include <iostream>

using namespace std;

int main()
{
    int n, a, b, o, ab;
    bool da_end = true;
    long long ab_counter = 0;

    cin >> n >> o >> a >> b >> ab;

    string grupa[1000];
    int jedinica[1000], reso[1000], resa[1000], resb[1000], resab[1000];

    for (int i = 0; i < n; i++){
        cin >> grupa[i] >> jedinica[i];
        if (grupa[i] == "O"){
            reso[i] = jedinica[i];
            o = o -jedinica[i];
            resa[i] = 0;
            resb[i] = 0;
            resab[i] = 0;
        }
    }
    cout << "nemoguce";       
}