#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;
			
		}
		
	}
	
	
	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;
	}
	
	if(o > po){
		printf("moguce");
		break;
	}
	
	if(a > pa && a > po){
		printf("moguce");
		break;
	}
	
	if(b > pb && b > po){
		printf("moguce");
		break;
	}
	
	if(ab > pab && ab > po && ab > pa && ab > pb){
		printf("moguce");
		break;
	}
}
	
	

	
	
	
	
	return 0;
}