#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	
	int n = 0, o = -1, a = -1, b = -1, ab = -1;
	
	int dO, da, db, dab;
	
	char g[100];
	int j;
	
	scanf("%d", &n);
	
	scanf("%d %d %d %d", &o, &a, &b, &ab);
	
	
	int i;
	
	int po = 0, pa = 0, pb = 0, pab = 0;
	
	for(i = 0; i < n; i++){
		
		scanf("%s %d", g, &j);
		
		if(strcmp(g, "B") == 0){
			pb = j;
			
		}
		
		if(strcmp(g, "A") == 0){
			pa = j;
			
		}
		
		if(strcmp(g, "O") == 0){
			po = j;
			
		}
		
		if(strcmp(g, "AB") == 0){
			pab = j;
			
		}
		
	}
	
	/*a = a + o;
	b = b + o;
	ab = o + a + b;*/
	
	o = o - po;
	if(o < 0){
		o = 0;
	}
	a = a + o;
	a = a - pa;
	if(a < 0){
		a = 0;
	}
	o = a - pa;
	if(o < 0){
		o = 0;
	}
	b = b + o;
	b = b - pb;
	if(b < 0){
		b = 0;
	}
	o = b - pb;
	if(o < 0){
		o = 0;
	}
	
	pb = o + a + b + ab;
	
	
	
	for(i = 0; i < 1; i++){
	if(o < po){
		printf("nemoguce");
		break;
	}
	
	if(a < pa && a < po){
		printf("nemoguce");
		break;
	}
	
	if(b < pb && b < po){
		printf("nemoguce");
		break;
	}
	
	if(ab < pab && ab < po && ab < pa && ab < pb){
		printf("nemoguce");
		break;
	}
	
	else{
		printf("moguce");
	}
	
	
}
	
	

	
	
	
	
	return 0;
}