using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split();
            string[] kgp = new string[n];
            int[] jed = new int[n];
            int[] kgb = new int[4];
            for (int i = 0; i < 4; i++)
                kgb[i] = int.Parse(s[i]);
            for (int i = 0; i < n; i++)
            {
                s = Console.ReadLine().Split();
                kgp[i] = s[0];
                jed[i] = int.Parse(s[1]);
            }
            for (int i = 0; i < n; i++)
            {
                if (kgp[i]=="O")
                {
                    kgb[0] = kgb[0] - jed[i];
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (kgp[i] == "A")
                {
                    if (kgb[1] >= jed[i])
                    {
                        kgb[1] = kgb[1] - jed[i];
                    }
                    else
                    {
                        kgb[0] = kgb[0] - (jed[i] - kgb[1]);
                        kgb[1] = 0;
                    }
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (kgp[i] == "B")
                {
                    if (kgb[2] >= jed[i])
                    {
                        kgb[2] = kgb[2] - jed[i];
                    }
                    else
                    {
                        kgb[0] = kgb[0] - (jed[i] - kgb[2]);
                        kgb[2] = 0;
                    }
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (kgp[i] == "AB")
                {
                    for (int j = 0; j < 4; j++)
                    {
                        if (kgb[j] > jed[i])
                            kgb[j] -= jed[i];
                        else
                        {
                            kgb[j] = kgb[j] - (jed[i] - kgb[j]);
                            kgb[j] = 0;
                        }
                    }
                }
            }

            bool moguce = true;
            for (int i=0;i<4;i++)
            {
                if (kgb[i] < 0)
                    moguce = false;
            }
            if(moguce)
                Console.WriteLine("moguce");
            else
                Console.WriteLine("nemoguce");
        }
    }
}