Problem:
Score : 600 points

Problem Statement

There is a game that involves three variables, denoted A, B, and C.

As the game progresses, there will be N events where you are asked to make a choice.
Each of these choices is represented by a string s_i. If s_i is AB, you must add 1 to A or B then subtract 1 from the other; if s_i is AC, you must add 1 to A or C then subtract 1 from the other; if s_i is BC, you must add 1 to B or C then subtract 1 from the other.

After each choice, none of A, B, and C should be negative.

Determine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.

Constraints

1 \leq N \leq 10^5

0 \leq A,B,C \leq 10^9

N, A, B, C are integers.

s_i is AB, AC, or BC.

Input

Input is given from Standard Input in the following format:

N A B C
s_1
s_2
:
s_N

Output

If it is possible to make N choices under the condition, print Yes; otherwise, print No.

Also, in the former case, show one such way to make the choices in the subsequent N lines. The (i+1)-th line should contain the name of the variable (A, B, or C) to which you add 1 in the i-th choice.

Sample Input 1

2 1 3 0
AB
AC

Sample Output 1

Yes
A
C

You can successfully make two choices, as follows:

In the first choice, add 1 to A and subtract 1 from B. A becomes 2, and B becomes 2.

In the second choice, add 1 to C and subtract 1 from A. C becomes 1, and A becomes 1.

Sample Input 2

3 1 0 0
AB
BC
AB

Sample Output 2

No

Sample Input 3

1 0 9 0
AC

Sample Output 3

No

Sample Input 4

8 6 9 1
AC
BC
AB
BC
AC
BC
AB
AB

Sample Output 4

Yes
C
B
B
C
C
B
A
A

Solution in C# (Mono-mcs 6.8.0.105) (judge verdict: Wrong Answer)

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

namespace ABC166
{
    public class Solve
    {
        public static void Main(string[] args)
        {
            new ABC_F();
        }
    }
    public class ABC_A
    {
        public ABC_A()
        {
            var s = Ex.Read;

            var str = s == "ABC" ? "ARC" : "ABC";
            str.Cw();
        }
    }
    public class ABC_B
    {
        public ABC_B()
        {
            var l = Ex.ReadIntArray();
            // N 人のすぬけ君  K 種類のお菓子
            var n = (int)l[0];
            var k = (int)l[1];

            // お菓子を1つも持っていない
            bool[] ans = new bool[n];

            for (int i = 0; i < k; i++)
            {
                var ii = Ex.ReadInt;
                var l2 = Ex.ReadIntArray();
                foreach (var v in l2) ans[v - 1] = true;
            }
            ans.Where(v => !v).Count().Cw();
        }
    }
    public class ABC_C
    {
        public ABC_C()
        {
            var l = Ex.ReadLongArray();
            // N 個の展望台があり、展望台 i の標高は H i です。  M 本の道
            // 道jは展望台Ajと展望台Bjを結んでいます
            var n = l[0];
            var m = l[1];

            var h = Ex.ReadLongArray();

            //展望台 i から一本の道を使って辿り着ける どの展望台よりも展望台 i の方が標高が高い
            //展望台 i から一本の道を使って辿り着ける 展望台が存在しない場合
            bool[] ans = new bool[n];

            for (int i = 0; i < m; i++)
            {
                var lm = Ex.ReadLongArray();
                var a = lm[0] - 1;
                var b = lm[1] - 1;
                if (h[a] <= h[b]) ans[a] = true;
                if (h[a] >= h[b]) ans[b] = true;
            }
            ans.Where(v => !v).Count().Cw();
        }
    }
    public class ABC_D
    {
        long x;
        public ABC_D()
        {
            x = Ex.ReadLong;
            if (0 == x)
            {
                $"0 0".Cw();
                return;
            }

            long[] arr = new long[150];

            //for (long i = 0; true; i++)
            //{
            //    if (i * i * i * i * i > 2 * 1000000000)
            //    {
            //        i.Cw();
            //        break;
            //    }
            //}
            for (long i = 0; i < 150; i++)
            {
                arr[i] = i * i * i * i * i;
                if (arr[i] == x)
                {
                    $"0 -{i}".Cw();
                    return;
                }
            }
            for (long j = 0; j < 150; j++)
            {
                for (long k = j; (arr[j] + arr[k]) <= x && k < 148; k++)
                {
                    //$"{j} -{k}".Cw();
                    if (arr[j] + arr[k] == x)
                    {
                        $"{j} -{k}".Cw();
                        return;
                    }
                }
                for (long k = j; k > 0 && (arr[j] - arr[k]) <= x; k--)
                {
                    // $"{j} {k}".Cw();
                    if (arr[j] - arr[k] == x)
                    {
                        $"{j} {k}".Cw();
                        return;
                    }
                }
            }
        }
    }
    public class ABC_E
    {
        public ABC_E()
        {
            long n = Ex.ReadLong;
            var l = Ex.ReadLongArray();
            long ans = 0;
            long[] arr = new long[n];
            for (long i = 0; i < n; i++)
            {
                if (i - l[i] >= 0)
                    arr[i - l[i]]++;
            }
            for (long i = 0; i < n; i++)
            {
                if (i + l[i] < n) ans += arr[i + l[i]];
            }
            ans.Cw();
        }
    }
    public class ABC_F
    {
        public ABC_F()
        {
            var l = Ex.ReadLongArray();
            var n = l[0];
            var a = l[1];
            var b = l[2];
            var c = l[3];
            List<long> ca = new List<long>();
            List<long> cb = new List<long>();
            List<long> cc = new List<long>();
            char[] arr1 = new char[n];
            char[] arr2 = new char[n];
            string[] arr = new string[n];
            for (long i = 0; i < n; i++)
            {
                var s = Ex.Read;
                if (s[0] == 'A') ca.Add(i);
                if (s[0] == 'B' || s[1] == 'B') cb.Add(i);
                if (s[1] == 'C') cc.Add(i);

                arr1[i] = s[0];
                arr2[i] = s[1];
                arr[i] = s;
            }
            long ma = (long)Math.Floor((ca.Count + a) / 2.0);
            long mb = (long)Math.Floor((cb.Count + b) / 2.0);
            long mc = (long)Math.Floor((cc.Count + c) / 2.0);

            string ans = "Yes";
            for (long i = 0; i < n; i++)
            {
                ans += '\n';
                if (arr[i] == "AB")
                {
                    if (ma < mb)
                    {
                        ma++;
                        mb--;
                        ans += arr[i][0];
                    }
                    else
                    {
                        ma--;
                        mb++;
                        ans += arr[i][1];
                    }
                }
                if (arr[i] == "AC")
                {
                    if (ma < mb)
                    {
                        ma++;
                        mc--;
                        ans += arr[i][0];
                    }
                    else
                    {
                        ma--;
                        mc++;
                        ans += arr[i][1];
                    }
                }
                if (arr[i] == "BC")
                {
                    if (ma < mb)
                    {
                        mb++;
                        mc--;
                        ans += arr[i][0];
                    }
                    else
                    {
                        mb--;
                        mc++;
                        ans += arr[i][1];
                    }
                }
                if (ma < 0 || mb < 0 || mc < 0)
                {
                    "No".Cw();
                    return;
                }
            }

            ans.Cw();
        }
    }
    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }

        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static string yesno(this bool b) { return b ? "yes" : "no"; }
        public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        public static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}