#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, o, a, b, ab;
	
	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;
		}
		
		else if(strcmp(g, "A") == 0){
			pa = j;
		}
		
		else if(strcmp(g, "O") == 0){
			po = j;
		}
		
		else if(strcmp(g, "AB") == 0){
			pab = j;
		}
		
	}
	
	if(po > o || po > pa || po > pb || pab > a || pab > b || pab > o){
		printf("nemoguce");
	}
	
	else{
		printf("moguce");
	}
	
	
	
	
	
	return 0;
}