using System;
using System.Collections;
class Program
{
    static void Main(string[] args)
    {
        int n = Convert.ToInt32(Console.ReadLine());
        string num = Console.ReadLine();
        string[] krv = num.Split(' ');
        int[] a = Array.ConvertAll<string, int>(krv, int.Parse);
        ArrayList potrb = new ArrayList();
        for (int i = 0; i < n; i++)
        {
            string pkrv = Console.ReadLine();
            string[] pkrv1 = pkrv.Split(' ');
            potrb.Add(pkrv1[0]);
            potrb.Add(Convert.ToInt32(pkrv1[1]));
        }
        int g1 = 0;
        int[,] res1 = new int[n, 4];
        for (int i = 0, j = 0; i < potrb.Count; i = i + 2, j++)
        {
            if (potrb[i].ToString().ToUpper() == "O")
            {
                if (a[0] == Convert.ToInt32(potrb[i + 1]))
                {
                    res1[j, 0] = a[0];
                    a[0] = 0;
                }
                else
                {
                    if (a[0] > Convert.ToInt32(potrb[i + 1]))
                    {
                        res1[j, 0] = Convert.ToInt32(potrb[i + 1]);
                        a[0] = a[0] - Convert.ToInt32(potrb[i + 1]);
                    }
                    else
                    {
                        g1++;
                    }
                }
            }
            else
            {
                if (potrb[i].ToString().ToUpper() == "A")
                {
                    if (a[1] == Convert.ToInt32(potrb[i + 1]))
                    {
                        res1[j, 1] = a[1];
                        a[1] = 0;
                    }
                    else
                    {
                        if (a[1] > Convert.ToInt32(potrb[i + 1]))
                        {
                            res1[j, 1] = Convert.ToInt32(potrb[i + 1]);
                            a[1] = a[1] - Convert.ToInt32(potrb[i + 1]);
                        }
                        else
                        {
                            if (a[0] >= Convert.ToInt32(potrb[i + 1]) - a[1])
                            {
                                res1[j, 1] = a[1];
                                res1[j, 0] = Convert.ToInt32(potrb[i + 1]) - a[1];
                                a[0] = a[0] - (Convert.ToInt32(potrb[i + 1]) - a[1]);
                            }
                            else
                            {
                                g1++;
                            }
                        }
                    }
                }
                else
                {
                    if (potrb[i].ToString().ToUpper() == "B")
                    {
                        if (a[2] == Convert.ToInt32(potrb[i + 1]))
                        {
                            res1[j, 2] = a[2];
                            a[2] = 0;
                        }
                        else
                        {
                            if (a[2] > Convert.ToInt32(potrb[i + 1]))
                            {
                                res1[j, 2] = Convert.ToInt32(potrb[i + 1]);
                                a[2] = a[2] - Convert.ToInt32(potrb[i + 1]);
                            }
                            else
                            {
                                if (a[0] >= Convert.ToInt32(potrb[i + 1]) - a[2])
                                {
                                    res1[j, 2] = a[2];
                                    res1[j, 0] = Convert.ToInt32(potrb[i + 1]) - a[2];
                                    a[0] = a[0] - (Convert.ToInt32(potrb[i + 1]) - a[2]);
                                }
                                else
                                {
                                    g1++;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (potrb[i].ToString().ToUpper() == "AB")
                        {
                            if (a[3] == Convert.ToInt32(potrb[i + 1]))
                            {
                                res1[j, 3] = a[3];
                                a[3] = 0;
                            }
                            else
                            {
                                if (a[3] > Convert.ToInt32(potrb[i + 1]))
                                {
                                    res1[j, 3] = Convert.ToInt32(potrb[i + 1]);
                                    a[3] = a[3] - Convert.ToInt32(potrb[i + 1]);
                                }
                                else
                                {
                                    if(a[1]>a[2])
                                    {
                                        if (a[1] >= Convert.ToInt32(potrb[i + 1]) - a[3])
                                        {
                                            res1[j, 3] = a[3];
                                            res1[j, 1] = Convert.ToInt32(potrb[i + 1]) - a[3];
                                            a[1] = a[1] - (Convert.ToInt32(potrb[i + 1]) - a[3]);
                                        }
                                        else
                                        {
                                            if (a[2] >= Convert.ToInt32(potrb[i + 1]) - a[3])
                                            {
                                                res1[j, 3] = a[3];
                                                res1[j, 2] = Convert.ToInt32(potrb[i + 1]) - a[3];
                                                a[2] = a[2] - (Convert.ToInt32(potrb[i + 1]) - a[3]);
                                            } else
                                            {
                                                if (a[0] >= Convert.ToInt32(potrb[i + 1]) - a[3])
                                                {
                                                    res1[j, 3] = a[3];
                                                    res1[j, 0] = Convert.ToInt32(potrb[i + 1]) - a[3];
                                                    a[0] = a[0] - (Convert.ToInt32(potrb[i + 1]) - a[3]);
                                                }
                                            }
                                        }
                                    } else
                                    {
                                        if (a[2] >= Convert.ToInt32(potrb[i + 1]) - a[3])
                                        {
                                            res1[j, 3] = a[3];
                                            res1[j, 2] = Convert.ToInt32(potrb[i + 1]) - a[3];
                                            a[2] = a[2] - (Convert.ToInt32(potrb[i + 1]) - a[3]);
                                        }
                                        else
                                        {
                                            if (a[1] >= Convert.ToInt32(potrb[i + 1]) - a[3])
                                            {
                                                res1[j, 3] = a[3];
                                                res1[j, 1] = Convert.ToInt32(potrb[i + 1]) - a[3];
                                                a[1] = a[1] - (Convert.ToInt32(potrb[i + 1]) - a[3]);
                                            }
                                            else
                                            {
                                                if (a[0] >= Convert.ToInt32(potrb[i + 1]) - a[3])
                                                {
                                                    res1[j, 3] = a[3];
                                                    res1[j, 0] = Convert.ToInt32(potrb[i + 1]) - a[3];
                                                    a[0] = a[0] - (Convert.ToInt32(potrb[i + 1]) - a[3]);
                                                }
                                                else
                                                {
                                                    g1++;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (g1 == 0)
        {
            Console.WriteLine("Moguce");
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    Console.Write("{0}   ", res1[i, j]);
                }
                Console.WriteLine();
            }
        }
        else
        {
            Console.WriteLine("Nemoguce");
        }
    }
}