#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
	int n,a,b,ab,o,i,brj,bra=0,brb=0,brab=0,bro=0;
	char kg[2],A[2],B[2],AB[2],O[2];
	printf("Unesite broj pacijenata u bolnici:");
	scanf("%d",&n);
	printf("Unesite O,A,B,AB zalihe bolnice:\n");
	scanf("%d %d %d %d",&o,&a,&b,&ab);
	printf("\nPodaci o pacijentima:\n");
	for(i=1;i<=n;i++)
	{
		printf("\nPacijent broj %d\n",i);
		scanf("%s",&kg[i]);
		scanf("%d",&brj);
	}
	for(i=1;i<=n;i++)
	{
		if(kg[i]=='A')
		{
			if(kg[i]>!a)
			{
				printf("\nMoguce!\n");
			
				bra=bra+1;
				if(bra>brab)
				{
					brab=brab+1;
				}
			}
			else
			{
				printf("\nNemoguce!\n");
			}
		}
		else if(kg[i]=='B')
		{
			if(kg[i]>!b)
			{
				printf("\nMoguce!\n");
				brb=brb+1;
				if(brb>brab)
				{
					brab=brab+1;
				}
			}
			else
			{
				printf("\nNemoguce!\n");
			}
		}
		else if(kg[i]=='AB')
		{
			if(kg[i]>!ab)
			{
			printf("\nMoguce!\n");
			brab=brab+1;
			if(brab>bra)
			{
				bra=bra+1;
			}
			else if(brab>brb)
			{
				brb=brb+1;
			}
			else if(brab>bro)
			{
				bro=bro+1;
			}
			}
			else
			{
				printf("\nNemoguce!\n");
			}
		}
		else if(kg[i]=='O')
		{
			if(kg[i]>!o)
			{
			printf("\nMoguce!\n");

			bro=bro+1;
			}
			else
			{
				printf("\nNemoguce!\n");
			}
		}
		printf("%d %d %d %d\n",bro,bra,brb,brab);
	}
}