using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int op = 0;
            int ap = 0;
            int bp = 0;
            int abp = 0;
            int[] jed = new int[n];
            int[] grup = new int[n];
            string s = Console.ReadLine();
            string[] s1 = s.Split(' ');
            int o = Convert.ToInt32(s1[0]);
            int a = Convert.ToInt32(s1[1]);
            int b = Convert.ToInt32(s1[2]);
            int ab = Convert.ToInt32(s1[3]);
            string t;
            for (int i = 0; i < n; i++) 
            {
                t = Console.ReadLine();
                string[] t1 = t.Split(' ');
                if (t1[0]=="O")
                {
                    grup[i] = 0;
                    jed[i] = Convert.ToInt32(t1[1]);
                    op += jed[i];
                }
                if (t1[0]=="A")
                {
                    grup[i] = 1;
                    jed[i] = Convert.ToInt32(t1[1]);
                    ap += jed[i];
                }
                if (t1[0]=="B")
                {
                    grup[i] = 2;
                    jed[i] = Convert.ToInt32(t1[1]);
                    bp += jed[i];
                }
                if (t1[0] == "AB")
                {
                    grup[i] = 3;
                    jed[i] = Convert.ToInt32(t1[1]);
                    abp += jed[i];
                }
            }
            int ov = o - op;
            int av = a - ap;
            int bv = b - bp;
            int abv = ab - abp;
            if (av < 0)
            {
                ov += av;
            }
            if (bv < 0)
            {
                ov += bv;
            }
            if (op > o || op + ap > o + a || op + bp > o + b || op + ap + bp + abp > o + a + b + ab)
            {
                Console.WriteLine("nemoguce");
            }
 
            else
            {
                Console.WriteLine("moguce");
                for (int i = 0; i < n; i++)
                {
                    if (grup[i] == 0)
                    {
                        Console.WriteLine(jed[i] + " " + 0 + " " + 0 + " " + 0);
                        o -= jed[i];
                    }
                    if (grup[i] == 1)
                    {
                        if (a >= jed[i])
                        {
                            Console.WriteLine(0 + " " + jed[i] + " " + 0 + " " + 0);
                            a -= jed[i];
                        }
                        else
                        {
                            Console.WriteLine(jed[i] - a + " " + a + " " + 0 + " " + 0);
                            a = 0;
                        }
                    }
                    if (grup[i] == 2)
                    {
                        if (b >= jed[i])
                        {
                            Console.WriteLine(0 + " " + 0 + " " + jed[i] + " " + 0);
                            b -= jed[i];
                        }
                        else
                        {
                            Console.WriteLine(jed[i] - b + " " + 0 + " " + b + " " + 0);
                            b = 0;
                        }
                    }
                    if (grup[i] == 3)
                    {
                        if (ab >= jed[i])
                        {
                            Console.WriteLine(0 + " " + 0 + " " + 0 + " " + jed[i]);
                            ab -= jed[i];
                        }
                        else 
                        {
                            int pot=jed[i]-ab;
                            int xo = 0;
                            int xa = 0;
                            int xb = 0;
                            while (av > 0 && pot > 0)
                            {
                                xa++;
                                pot--;
                                av--;
                            }
                            while (bv > 0 && pot > 0)
                            {
                                xb++;
                                pot--;
                                bv--;
                            }
                            while (pot > 0)
                            {
                                xo++;
                                pot--;
                            }
                            Console.WriteLine(xo + " " + xa + " " + xb + " " + ab);
                            ab = 0;
                        }
                    }
                }
            }
        }
    }
}