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: Runtime Error)

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
    {
        long n;
        long[] count = new long[3];
        long[] input = new long[3];
        string[] arr;

        public ABC_F()
        {
            var l = Ex.ReadLongArray();
            n = l[0];
            input[0] = l[1];
            input[1] = l[2];
            input[2] = l[3];

            arr = new string[n];
            for (long i = 0; i < n; i++)
            {
                var s = Ex.Read;
                count[s[0] - 'A']++;
                count[s[1] - 'A']++;

                arr[i] = s;
            }
            count[0] = (long)Math.Floor((count[0] + input[0]) / 2.0);
            count[1] = (long)Math.Floor((count[1] + input[1]) / 2.0);
            count[2] = (long)Math.Floor((count[2] + input[2]) / 2.0);
            if (!dfs("Yes", 0))
            {
                "No".Cw();
            }

        }

        bool dfs(string s, long i)
        {
            if (input[0] < 0 || input[1] < 0 || input[2] < 0)
            {
                return false;
            }
            if (i >= n)
            {
                s.Cw();
                return true;
            }

            s += '\n';

            var c0 = s[0] - 'A';
            var c1 = s[1] - 'A';
            if (count[c0] < count[c1])
            {
                input[c0]++;
                input[c1]--;
                count[c0]++;
                count[c1]--;
                return dfs(s + arr[i][0], i + 1);
            }
            else if (count[c0] > count[c1])
            {
                input[c0]--;
                input[c1]++;
                count[c0]--;
                count[c1]++;
                return dfs(s + arr[i][1], i + 1);
            }
            else
            {
                input[c0]++;
                input[c1]--;
                count[c0]++;
                count[c1]--;
                if (dfs(s + arr[i][0], i + 1)) return true;
                else
                {
                    input[c0] -= 2;
                    input[c1] += 2;
                    count[c0] -= 2;
                    count[c1] += 2;
                    return dfs(s + arr[i][1], i + 1);
                }
            }
        }
    }
    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; }
    }
}