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

namespace Transfuzija_krvi
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] m = new int[n, 4];
            string[] s = Console.ReadLine().Split();
            int o = int.Parse(s[0]);
            int a = int.Parse(s[1]);
            int b = int.Parse(s[2]);
            int ab = int.Parse(s[3]);
            bool t = true;
            int y = 0;
            int ind = 0;
            for (int i = 0; i < n; i++)
            {
                string[] st = Console.ReadLine().Split();
                string g = st[0];
                int x = int.Parse(st[1]);
                if (g == "O")
                {
                    o -= x;
                    if (o < 0)
                    {
                        t = false;
                        break;
                    }
                    else
                        m[i, 0] = x;
                }
                else if (g == "A")
                {
                    if (x > a)
                    {
                        x -= a;
                        m[i, 1] = a;
                        a = 0;
                        if (x > o)
                        {
                            t = false;
                            break;
                        }
                        else
                        {
                            o -= x;
                            m[i, 0] = x;
                        }
                    }
                    else
                    {
                        a -= x;
                        m[i, 1] = x;
                    }
                }
                else if (g == "B")
                {
                    if (x > b)
                    {
                        x -= b;
                        m[i, 2] = b;
                        b = 0;
                        if (x > o)
                        {
                            t = false;
                            break;
                        }
                        else
                        {
                            o -= x;
                            m[i, 0] = x;
                        }
                    }
                    else
                    {
                        b -= x;
                        m[i, 2] = x;
                    }
                }
                else
                {
                    y = x;
                    ind = i;
                }
            }
            if (!t || o + a + b + ab < y)
                Console.WriteLine("nemoguce");
            else
            {
                Console.WriteLine("moguce");
                if (y < ab)
                {
                    m[ind, 3] = y;
                }
                else
                    m[ind, 3] = ab;
                y -= ab;
                if (y > 0)
                {
                    if (o > 0)
                    {
                        if (y < o)
                            m[ind, 0] = y;
                        else
                            m[ind, 0] = o;
                        y -= o;
                    }
                }
                if (y > 0)
                {
                    if (a > 0)
                    {
                        if (y < a)
                            m[ind, 1] = y;
                        else
                            m[ind, 1] = a;
                        y -= a;
                    }
                }
                if (y > 0)
                {
                    m[ind, 2] = y;
                }
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        Console.Write(m[i, j] + " ");
                    }
                    Console.WriteLine();
                }
            }
        }
    }
}