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-----
2 1 3 0
AB
AC

-----Sample Output-----
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.

Difficulty: interview

Starter code:

Solutions:
def main():
    n, a, b, c = map(int, input().split())
    Ss = [input() for _ in range(n)]
    ans = []
    f = True
    if a+b+c == 0:
        print("No")
    elif a+b+c == 1:
        for i in range(n):
            if Ss[i] == "AB":
                if a == 0 and b == 0:
                    f = False
                    break
                else:
                    if a == 1:
                        ans.append("B")
                        a, b = a-1, b+1
                    else:
                        ans.append("A")
                        a, b = a+1, b-1
            elif Ss[i] == "AC":
                if a == 0 and c == 0:
                    f = False
                    break
                else:
                    if a == 1:
                        ans.append("C")
                        a, c = a-1, c+1
                    else:
                        ans.append("A")
                        a, c = a+1, c-1
            else:
                if b == 0 and c == 0:
                    f = False
                    break
                else:
                    if b == 1:
                        ans.append("C")
                        b, c = b-1, c+1
                    else:
                        ans.append("B")
                        b, c = b+1, c-1
        if f:
            print("Yes")
            for v in ans:
                print(v)
        else:
            print("No")
    else:
        for i in range(n):
            if Ss[i] == "AB":
                if a == 0 and b == 0:
                    f = False
                    break
                else:
                    if i < n-1:
                        if Ss[i+1] == "AB":
                            if b == 0:
                                ans.append("B")
                                a, b = a-1, b+1
                            else:
                                ans.append("A")
                                a, b = a+1, b-1
                        elif Ss[i+1] == "AC":
                            if b == 0:
                                ans.append("B")
                                a, b = a-1, b+1
                            else:
                                ans.append("A")
                                a, b = a+1, b-1
                        else:
                            if a == 0:
                                ans.append("A")
                                a, b = a+1, b-1
                            else:
                                ans.append("B")
                                a, b = a-1, b+1
                    else:
                        if a == 0 and b == 0:
                            f = False
                            break
                        elif b == 0:
                            ans.append("B")
                            a, b = a-1, b+1
                        else:
                            ans.append("A")
                            a, b = a+1, b-1
            elif Ss[i] == "AC":
                if a == 0 and c == 0:
                    f = False
                    break
                else:
                    if i < n-1:
                        if Ss[i+1] == "AB":
                            if c == 0:
                                ans.append("C")
                                a, c = a-1, c+1
                            else:
                                ans.append("A")
                                a, c = a+1, c-1
                        elif Ss[i+1] == "AC":
                            if c == 0:
                                ans.append("C")
                                a, c = a-1, c+1
                            else:
                                ans.append("A")
                                a, c = a+1, c-1
                        else:
                            if a == 0:
                                ans.append("A")
                                a, c = a+1, c-1
                            else:
                                ans.append("C")
                                a, c = a-1, c+1
                    else:
                        if a == 0 and c == 0:
                            f = False
                            break
                        elif c == 0:
                            ans.append("C")
                            a, c = a-1, c+1
                        else:
                            ans.append("A")
                            a, c = a+1, c-1
            else:
                if b == 0 and c == 0:
                    f = False
                    break
                else:
                    if i < n-1:
                        if Ss[i+1] == "AB":
                            if c == 0:
                                ans.append("C")
                                b, c = b-1, c+1
                            else:
                                ans.append("B")
                                b, c = b+1, c-1
                        elif Ss[i+1] == "AC":
                            if b == 0:
                                ans.append("B")
                                b, c = b+1, c-1
                            else:
                                ans.append("C")
                                b, c = b-1, c+1
                        else:
                            if b == 0:
                                ans.append("B")
                                b, c = b+1, c-1
                            else:
                                ans.append("C")
                                b, c = b-1, c+1
                    else:
                        if b == 0 and c == 0:
                            f = False
                            break
                        elif c == 0:
                            ans.append("C")
                            b, c = b-1, c+1
                        else:
                            ans.append("B")
                            b, c = b+1, c-1
        if f:
            print("Yes")
            for v in ans:
                print(v)
        else:
            print("No")

def __starting_point():
    main()
__starting_point()

import sys

sys.setrecursionlimit(10 ** 7)

# ----------

INF = float("inf")
MOD = 10 ** 9 + 7

N, A, B, C = list(map(int, input().split()))
num = [A, B, C]
S = []
for i in range(N):
    S.append(input().strip())
S.append('AB')

ans = []
for i in range(N):
    s1 = S[i][0]
    s2 = S[i][1]
    n1 = num["ABC".index(s1)]
    n2 = num["ABC".index(s2)]

    if n1 == n2 == 0:
        print("No")
        return

    s_add = ""
    s_sub = ""
    if n1 == 0:
        s_add = s1
        s_sub = s2
    elif n2 == 0:
        s_add = s2
        s_sub = s1
    elif s1 in S[i + 1]:
        s_add = s1
        s_sub = s2
    else:
        s_add = s2
        s_sub = s1

    num["ABC".index(s_add)] += 1
    num["ABC".index(s_sub)] -= 1
    ans.append(s_add)

print('Yes')
for a in ans:
    print(a)


n,a,b,c = map(int,input().split())
s_list = []
for i in range(n):
    s = input()
    s_list.append(s)

if a+b+c == 0:
    print("No")
    return

move = []
if a+b+c == 1:
    for i in range(n):
        if s_list[i] == "AB":
            if a == 0:
                a+=1
                b-=1
                move.append("A")
            else:
                b+=1
                a-=1
                move.append("B")
        if s_list[i] == "BC":
            if b == 0:
                b+=1
                c-=1
                move.append("B")
            else:
                c+=1
                b-=1
                move.append("C")
        if s_list[i] == "AC":
            if a == 0:
                a+=1
                c-=1
                move.append("A")
            else:
                c+=1
                a-=1
                move.append("C")
        if min(a,b,c) < 0:
            print("No")
            return

    print("Yes")
    for i in move:
        print(i)            
    
else:
    for i in range(n):
        if i < n-1:
            s_next = s_list[i+1]
        if s_list[i] == "AB":
            if a == 1 and b == 1 and s_next != "AB":
                if s_next == "BC":
                    b+=1
                    a-=1
                    move.append("B")
                else:
                    a+=1
                    b-=1
                    move.append("A")
            else:
                if a < b:
                    a+=1
                    b-=1
                    move.append("A")
                else:
                    b+=1
                    a-=1
                    move.append("B")
        if s_list[i] == "BC":
            if b == 1 and c == 1 and s_next != "BC":
                if s_next == "AB":
                    b+=1
                    c-=1
                    move.append("B")
                else:
                    c+=1
                    b-=1
                    move.append("C")
            else:
                if b < c:
                    b+=1
                    c-=1
                    move.append("B")
                else:
                    c+=1
                    b-=1
                    move.append("C")
        if s_list[i] == "AC":
            if a == 1 and c == 1 and s_next != "AC":
                if s_next == "AB":
                    a+=1
                    c-=1
                    move.append("A")
                else:
                    c+=1
                    a-=1
                    move.append("C")
            else:
                if a < c:
                    a+=1
                    c-=1
                    move.append("A")
                else:
                    c+=1
                    a-=1
                    move.append("C") 

        if min(a,b,c) < 0:
            print("No")
            return
    print("Yes")
    for i in move:
        print(i)     

import sys
input = sys.stdin.readline
n, a, b, c = map(int, input().split())
S = [input().rstrip().replace("AC", "CA") for _ in range(n)]
D = ["AB", "BC", "CA"]
X = [a+b, b+c, c+a]
L = []
for i, s in enumerate(S):
  k = D.index(s)
  if X[k] == 0:
    print("No")
    return
  if X[(k+1)%3] == 1 and X[(k+2)%3] == 1 and i < n-1:
    l = D.index(S[i+1])
    if l == (k+1)%3:
      X[(k+1)%3] += 1
      X[(k+2)%3] -= 1
      L.append(s[1])
    else:
      X[(k+2)%3] += 1
      X[(k+1)%3] -= 1
      L.append(s[0])
  else:
    if X[(k+1)%3] < X[(k+2)%3]:
      X[(k+1)%3] += 1
      X[(k+2)%3] -= 1
      L.append(s[1])
    else:
      X[(k+2)%3] += 1
      X[(k+1)%3] -= 1
      L.append(s[0])
print("Yes")
print(*L, sep="\n")

#F
import sys
from collections import Counter as cc

N,A,B,C = list(map(int, input().split()))
abc = []
ans = []

for i in range(N):
    abc.append(input())
abc.append("")

a = abc.count("AB")+abc.count("AC")
b = abc.count("AB")+abc.count("BC")
c = abc.count("AC")+abc.count("BC")


for i, (s, ns) in enumerate(zip(abc,abc[1:])):
    if s == "AB":
        if A > B or (A == B and i != N-1 and ("AB" in ns or "BC" in ns)):
            A -= 1
            B += 1
            ans.append("B")
        else:
            A += 1
            B -= 1
            ans.append("A")
    elif s == "AC":
        a -= 1
        c -= 1
        if A > C or (A == C and i != N-1 and ("AC" in ns or "BC" in ns)):
            A -= 1
            C += 1
            ans.append("C")
        else:
            A += 1
            C -= 1
            ans.append("A")
    else:
        c -= 1
        b -= 1
        if B > C or (B == C and i != N-1 and ("AC" in ns or "BC" in ns)):
            C += 1
            B -= 1
            ans.append("C")
        else:
            C -= 1
            B += 1
            ans.append("B")
    if A < 0 or B < 0 or C < 0:
        print("No")
        return

print("Yes")
for i in range(N):
    print(str(ans[i]))

import sys
readline = sys.stdin.readline

def main():
  N, a, b, c = map(int, readline().split())
  A = {"A":a, "B":b, "C":c}
  S = []
  for i in range(N):
    l = readline().strip()
    S.append([l[0], l[1]])

  ans = ""
  ret = False
  for i in range(N):
    if A[S[i][0]] == 0 and A[S[i][1]] == 0:
      break
    if i == N-1:
      if A[S[i][0]] > 0:
        ans += S[i][1]
      else:
        ans += S[i][0]
      ret = True
      break
    if A["A"] + A["B"] + A["C"] == 1:
      if A[S[i][0]] == 1:
        if S[i][0] in S[i+1] and S[i][1] not in S[i+1]:
          break
        else:
          A[S[i][0]] -= 1
          A[S[i][1]] += 1
          ans += S[i][1]
          continue
      else:
        if S[i][1] in S[i+1] and S[i][0] not in S[i+1]:
          break
        else:
          A[S[i][0]] += 1
          A[S[i][1]] -= 1
          ans += S[i][0]
          continue
    if A[S[i][0]] == 0:
      A[S[i][0]] += 1
      A[S[i][1]] -= 1
      ans += S[i][0]
      continue
    elif A[S[i][1]] == 0:
      A[S[i][0]] -= 1
      A[S[i][1]] += 1
      ans += S[i][1]
      continue
    elif S[i][0] in S[i+1]:
      A[S[i][0]] += 1
      A[S[i][1]] -= 1
      ans += S[i][0]
      continue
    else:
      A[S[i][0]] -= 1
      A[S[i][1]] += 1
      ans += S[i][1]
      continue

  if ret:
    print("Yes")
    for i in range(N):
      print(ans[i])
  else:
    print("No")

def __starting_point():
  main()
__starting_point()

def solve(writer):
    N, A, B, C = list(map(int, input().split()))
    variables = {
        'A': A,
        'B': B,
        'C': C
    }

    queries = (list(input()) for _ in range(N))

    buffer = list()
    b = ''

    for i in range(N):
        if not buffer:
            t1, t2 = next(queries)
        else:
            b = buffer.pop()
            if b == 'pass':
                continue
            else:
                t1, t2 = list(b)

        v1 = variables[t1]
        v2 = variables[t2]

        if v1 == v2 == 0:
            return False
        elif v1 == v2 == 1:
            if i == N-1:
                writer.append(t1)
                return True

            nt1, nt2 = next(queries)
            if len({t1, t2, nt1, nt2}) == 2:
                buffer.append('pass')
                writer.append(t1)
                writer.append(t2)
                continue

            if t1 in {nt1, nt2}:
                variables[t1] += 1
                variables[t2] -= 1
                writer.append(t1)
            else:
                variables[t1] -= 1
                variables[t2] += 1
                writer.append(t2)

            buffer.append(''.join([nt1, nt2]))

        elif v1 > v2:
            variables[t1] -= 1
            variables[t2] += 1
            writer.append(t2)
        elif v2 > v1:
            variables[t1] += 1
            variables[t2] -= 1
            writer.append(t1)
        else:
            variables[t1] += 1
            variables[t2] -= 1
            writer.append(t1)

    return True


def main():
    writer = list()
    ok = solve(writer)
    if ok:
        print('Yes')
        for w in writer:
            print(w)
    else:
        print('No')


def __starting_point():
    main()

__starting_point()

import sys
sys.setrecursionlimit(10**7)
ans=''
def dfs(a,b,c,t):
    nonlocal ans
    if a<0 or b<0 or c<0:
        return False
    if t==N:
        return True
    if s[t]=='AB':
        if dfs(a-1,b+1,c,t+1):
            ans+='B'
            return True
        elif dfs(a+1,b-1,c,t+1):
            ans+='A'
            return True
    if s[t]=='BC':
        if dfs(a,b-1,c+1,t+1):
            ans+='C'
            return True
        elif dfs(a,b+1,c-1,t+1):
            ans+='B'
            return True
    if s[t]=='AC':
        if dfs(a+1,b,c-1,t+1):
            ans+='A'
            return True
        if dfs(a-1,b,c+1,t+1):
            ans+='C'
            return True
    return False

N,A,B,C=map(int,input().split())
s=[input() for i in range(N)]

if dfs(A,B,C,0):
    print('Yes')
    print(*ans[::-1],sep='\n')
else:
    print('No')

def update_vrs(vrs, idx, s):
    if idx == 0:
        vrs[s[0]] += 1
        vrs[s[1]] -= 1
    elif idx == 1:
        vrs[s[0]] -= 1
        vrs[s[1]] += 1
    else:
        raise ValueError()


def process1(vrs, lst_s):
    selects = []
    for s in lst_s:
        if vrs[s[0]] == 0 and vrs[s[1]] == 0:
            return False, None
        elif vrs[s[0]] == 0:
            selects.append(s[0])
            update_vrs(vrs, 0, s)
        else:  # when vrs[s[1]] == 1:
            selects.append(s[1])
            update_vrs(vrs, 1, s)
    return True, selects


def process2(vrs, lst_s):
    selects = []
    for i, s in enumerate(lst_s):
        if vrs[s[0]] == 0 and vrs[s[1]] == 0:
            return False, None
        elif vrs[s[0]] == 0:
            selects.append(s[0])
            update_vrs(vrs, 0, s)
        elif vrs[s[1]] == 0:
            selects.append(s[1])
            update_vrs(vrs, 1, s)
        else:
            if i == len(lst_s) - 1:
                selects.append(s[0])
            else:
                next_s = lst_s[i + 1]
                if s[0] in next_s:
                    selects.append(s[0])
                    update_vrs(vrs, 0, s)
                else:
                    selects.append(s[1])
                    update_vrs(vrs, 1, s)
    return True, selects


def main():
    vrs = {}
    n, vrs['A'], vrs['B'], vrs['C'] = [int(v) for v in input().split(' ')]
    lst_s = []
    for _ in range(n):
        lst_s.append(input().strip())

    sum_abc = vrs['A'] + vrs['B'] + vrs['C']

    if sum_abc == 0:
        ans = False
    elif sum_abc == 1:
        ans, selects = process1(vrs, lst_s)
    else:
        ans, selects = process2(vrs, lst_s)

    if ans is True:
        print('Yes')
        for s in selects:
            print(s)
    else:
        print('No')


def __starting_point():
    main()

__starting_point()

N, A, B, C = list(map(int,input().split()))
ans = []
flag = True
cnt = 0
while True:
  cnt += 1
  if cnt > N:
    break
  s = input()
  if s == 'AB':
    if A == B == 0:
      flag = False
      break
    elif A == B == 1:
      if cnt == N:
        ans.append('A')
        break
      else:
        cnt += 1
        s = input()
        if s == 'AB':
          ans.append('A')
          ans.append('B')
          continue
        elif s == 'AC':
          ans.append('A')
          ans.append('C')
          B -= 1
          C += 1
          continue
        else:
          ans.append('B')
          ans.append('C')
          A -= 1
          C += 1
          continue
    elif A >= B:
      A -= 1
      B += 1
      ans.append('B')
      continue
    else:
      B -= 1
      A += 1
      ans.append('A')
      continue
  elif s == 'BC':
    if B == C == 0:
      flag = False
      break
    elif B == C == 1:
      if cnt == N:
        ans.append('B')
        break
      else:
        cnt += 1
        s = input()
        if s == 'BC':
          ans.append('B')
          ans.append('C')
          continue
        elif s == 'AB':
          ans.append('B')
          ans.append('A')
          C -= 1
          A += 1
          continue
        else:
          ans.append('C')
          ans.append('A')
          B -= 1
          A += 1
          continue
    elif B >= C:
      B -= 1
      C += 1
      ans.append('C')
      continue
    else:
      C -= 1
      B += 1
      ans.append('B')
      continue 
  else:
    if C == A == 0:
      flag = False
      break
    elif C == A == 1:
      if cnt == N:
        ans.append('C')
        break
      else:
        cnt += 1
        s = input()
        if s == 'AC':
          ans.append('C')
          ans.append('A')
          continue
        elif s == 'BC':
          ans.append('C')
          ans.append('B')
          A -= 1
          B += 1
          continue
        else:
          ans.append('A')
          ans.append('B')
          C -= 1
          B += 1
          continue
    elif A >= C:
      A -= 1
      C += 1
      ans.append('C')
      continue
    else:
      C -= 1
      A += 1
      ans.append('A')
      continue
if flag:
  print('Yes')
  for item in ans:
    print(item)
else:
  print('No')


N, A, B, C = list(map(int, input().split()))
d = {"A": A, "B": B, "C": C}
l = [input() for _ in range(N)]
v = A+B+C

def solve():
    res = []
    if v==0:
        return []
    elif v==1:
        for i in l:
            a, b = i
            if d[a]==0 and d[b]==0:
                return []
            elif d[a]>d[b]:
                d[a] -= 1
                d[b] += 1
                res.append(b)
            else:
                d[a] += 1
                d[b] -= 1
                res.append(a)
    else:
        a, b = l[0]
        if d[a]==0 and d[b]==0:
            return []
        else:
            for i, j in enumerate(l):
                a, b = j
                if d[a]>d[b]:
                    d[a] -= 1
                    d[b] += 1
                    res.append(b)
                elif d[a]==d[b]==1 and i+1<N:
                    e = set(l[i+1])&set([a, b])
                    if len(e)==1:
                        f = e.pop()
                        g = b if f==a else a
                        d[f] += 1
                        d[g] -= 1
                        res.append(f)
                    else:
                        d[a] -= 1
                        d[b] += 1
                        res.append(b)
                else:
                    d[a] += 1
                    d[b] -= 1
                    res.append(a)
    return res


r = solve()
if r:
    print("Yes")
    for i in r:
        print(i)
else:
    print("No")


import sys
sys.setrecursionlimit(10**7)
ans=''
def dfs(a,b,c,t):
    nonlocal ans
    if a<0 or b<0 or c<0:
        return False
    if t==N:
        return True
    if s[t]=='AB':
        if dfs(a-1,b+1,c,t+1):
            ans+='B'
            return True
        elif dfs(a+1,b-1,c,t+1):
            ans+='A'
            return True
    if s[t]=='BC':
        if dfs(a,b-1,c+1,t+1):
            ans+='C'
            return True
        elif dfs(a,b+1,c-1,t+1):
            ans+='B'
            return True
    if s[t]=='AC':
        if dfs(a+1,b,c-1,t+1):
            ans+='A'
            return True
        if dfs(a-1,b,c+1,t+1):
            ans+='C'
            return True
    return False

N,A,B,C=map(int,input().split())
s=[input() for i in range(N)]

if dfs(A,B,C,0):
    print('Yes')
    print(*ans[::-1],sep='\n')
else:
    print('No')


N, A, B, C = map(int, input().split())
S = [input() for _ in range(N)]
ans = []
for i, s in enumerate(S):
    if s == "AB":
        if A == 0:
            A += 1
            B -= 1
            ans.append("A")
        elif B == 0:
            A -= 1
            B += 1
            ans.append("B")
        else:
            if i + 1 == N or S[i + 1] == "AB":
                A += 1
                B -= 1
                ans.append("A")
            else:
                if S[i + 1] == "BC":
                    A -= 1
                    B += 1
                    ans.append("B")
                else:
                    A += 1
                    B -= 1
                    ans.append("A")

        if A < 0 or B < 0:
            print("No")
            return
    elif s == "BC":
        if B == 0:
            B += 1
            C -= 1
            ans.append("B")
        elif C == 0:
            B -= 1
            C += 1
            ans.append("C")
        else:
            if i + 1 == N or S[i + 1] == "BC":
                B += 1
                C -= 1
                ans.append("B")
            else:
                if S[i + 1] == "AB":
                    B += 1
                    C -= 1
                    ans.append("B")
                else:
                    B -= 1
                    C += 1
                    ans.append("C")

        if B < 0 or C < 0:
            print("No")
            return
    else:
        if C == 0:
            C += 1
            A -= 1
            ans.append("C")
        elif A == 0:
            C -= 1
            A += 1
            ans.append("A")
        else:
            if i + 1 == N or S[i + 1] == "AC":
                A += 1
                C -= 1
                ans.append("A")
            else:
                if S[i + 1] == "AB":
                    A += 1
                    C -= 1
                    ans.append("A")
                else:
                    A -= 1
                    C += 1
                    ans.append("C")

        if A < 0 or C < 0:
            print("No")
            return
print("Yes")
for x in ans:
    print(x)

#!/usr/bin/env python3

n, a, b, c = map(int, input().split())
S = []
for _ in range(n):
    S.append(input())

ans = []
for i in range(n):
    if S[i] == "AB":
        if a == b == 0:
            print("No")
            return
        elif a < b or (a == b and i != n - 1 and "A" in S[i+1]):
            ans.append("A")
            a += 1
            b -= 1
        else:
            ans.append("B")
            a -= 1
            b += 1
    elif S[i] == "BC":
        if b == c == 0:
            print("No")
            return
        elif c < b or (c == b and i != n - 1 and "C" in S[i+1]):
            ans.append("C")
            c += 1
            b -= 1
        else:
            ans.append("B")
            c -= 1
            b += 1
    else:
        if c == a == 0:
            print("No")
            return
        elif c < a or (c == a and i != n - 1 and "C" in S[i+1]):
            ans.append("C")
            c += 1
            a -= 1
        else:
            ans.append("A")
            c -= 1
            a += 1
print("Yes")
print("\n".join(ans))
return

import sys
readline = sys.stdin.readline

N,A,B,C = list(map(int,readline().split()))

# 0,0を作ってはいけない
# 基本的には小さいほうに1を足す
# 両方とも1の場合は、次の操作で選ばれるほうに1を足す
# 両方とも次の操作で選ばれるときはどちらに足してもよい

S = [readline().rstrip() for i in range(N)]
ans = []

for i in range(N):
  if S[i] == "AB":
    if A == 0 and B == 0:
      print("No")
      return
    if A < B:
      ans += ["A"]
      A += 1
      B -= 1
    elif A > B:
      ans += ["B"]
      B += 1
      A -= 1
    else:
      if i + 1 < N and "A" in S[i + 1]:
        ans += ["A"]
        A += 1
        B -= 1
      else:
        ans += ["B"]
        B += 1
        A -= 1
  if S[i] == "AC":
    if A == 0 and C == 0:
      print("No")
      return
    if A < C:
      ans += ["A"]
      A += 1
      C -= 1
    elif A > C:
      ans += ["C"]
      C += 1
      A -= 1
    else:
      if i + 1 < N and "A" in S[i + 1]:
        ans += ["A"]
        A += 1
        C -= 1
      else:
        ans += ["C"]
        C += 1
        A -= 1
  if S[i] == "BC":
    if B == 0 and C == 0:
      print("No")
      return
    if B < C:
      ans += ["B"]
      B += 1
      C -= 1
    elif B > C:
      ans += ["C"]
      C += 1
      B -= 1
    else:
      if i + 1 < N and "B" in S[i + 1]:
        ans += ["B"]
        B += 1
        C -= 1
      else:
        ans += ["C"]
        C += 1
        B -= 1
print("Yes")
for a in ans:
  print(a)
      
    
    

  


# 初手 1 1 1 なら絶対成功 (greedy)
# どこかの状態で 1 1 1 を作れるなら絶対成功 (greedy)
# 0 1 2 なら絶対成功 (greedy)
# 0 0 3 で、初手がAB以外なら絶対成功 (greedy)
# 0 0 0 なら絶対失敗
#
# 初手で成否が分からないのは
# 0 1 1
# 0 0 2
# 0 0 1
#
# 0 0 1 は greedyにやるしかない
# 0 0 2 は、少なくとも1回はgreedy
#
# 結局、各回のgreedyでは問題になるのは
# 0 1 1 のときのみ
# これは1個先を読めば十分


def select(x, y, ops, i, z):
    # true -> x を増やす
    if not(x == 1 and y == 1 and i < len(ops) - 1):
        if x < y:
            return True
        else:
            return False

    # x = y = 1, i < len(ops) - 1
    # 先読みして xz なら x を増やす
    # 先読みして xy なら y を増やす
    # 先読みして xy なら どっちでもいい
    op = ops[i]
    nop = ops[i+1]

    oo = (op, nop)
    if op == nop:
        return True

    if oo in [("AB", "AC"), ("BC", "AB"), ("AC", "AB")]:
        return True

    return False

def main():
    nabc = [int(_x) for _x in input().split()]
    n = nabc[0]
    a = nabc[1]
    b = nabc[2]
    c = nabc[3]

    ops = []
    for i in range(n):
        ops.append(input())

    result = []
    for i in range(n):
        op = ops[i]
        if op == "AB":
            if select(a, b, ops, i, c):
                result.append("A")
                a+=1
                b-=1
            else:
                result.append("B")
                a-=1
                b+=1
        if op == "AC":
            if select(a, c, ops, i, b):
                result.append("A")
                a+=1
                c-=1
            else:
                result.append("C")
                a-=1
                c+=1
        if op == "BC":
            if select(b, c, ops, i, a):
                result.append("B")
                b+=1
                c-=1
            else:
                result.append("C")
                b-=1
                c+=1
        if a <0 or b<0 or c<0:
            print("No")
            return

    print("Yes")
    for r in result:
        print(r)

main()


import sys
n,a,b,c = map(int, input().split())
 
s = list()
for i in range(n):
    s.append(input())
 
r = list()
 
for i in range(n):
    if s[i]=='AB':
        if a>b:
            r.append('B')
            a=a-1
            b=b+1
        elif a<b:
            r.append('A')
            a=a+1
            b=b-1
        else:
            if i==n-1 or 'A' in s[i+1]:
                r.append('A')
                a=a+1
                b=b-1
            else: 
                r.append('B')
                a=a-1
                b=b+1
    elif s[i]=='AC':
        if a>c:
            r.append('C')
            a=a-1
            c=c+1
        elif a<c:
            r.append('A')
            a=a+1
            c=c-1
        else:
            if i==n-1 or 'A' in s[i+1]:
                r.append('A')
                a=a+1
                c=c-1
            else: 
                r.append('C')
                a=a-1
                c=c+1
    else:
        if b>c:
            r.append('C')
            b=b-1
            c=c+1
        elif b<c:
            r.append('B')
            b=b+1
            c=c-1
        else:
            if i==n-1 or 'B' in s[i+1]:
                r.append('B')
                b=b+1
                c=c-1
            else: 
                r.append('C')
                b=b-1
                c=c+1
    if min(a,b,c)<0:
        print('No')
        return
 
 
print('Yes')
for str in r:
    print(str)

#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,A,B,C = list(map(int, input().split()))
    array = [A,B,C]
    string = ['A','B','C']
    si = [] # AB:0,BC:1,AC:2
    if A+B+C <= 0:
        print('No')
        return
    for _ in range(N):
        s = input()
        si += (0 if s == 'AB' else 1 if s == 'BC' else 2),

    ans = []
    for i in range(len(si)):
        s = si[i]
        index = -3 if s == 0 else -2 if s == 1 else -1
        if array[index] == 0:
            array[index] += 1
            array[index+1] -= 1
            ans += string[index],
        elif array[index+1] == 0:
            array[index] -= 1
            array[index+1] += 1
            ans += string[index+1],
        elif array[index] == 1 and array[index+1] == 1:
            if i+1 >= len(si):
                array[index] += 1
                array[index+1] -= 1
                ans += string[index],
            else:
                if si[i+1] != (index+1)%3:
                    array[index] += 1
                    array[index+1] -= 1
                    ans += string[index],
                else:
                    array[index] -= 1
                    array[index+1] += 1
                    ans += string[index+1],
        elif array[index] == 1:
            array[index] += 1
            array[index+1] -= 1
            ans += string[index],
        else:
            array[index] -= 1
            array[index+1] += 1
            ans += string[index+1],

        if array[0] < 0 or array[1] < 0 or array[2] < 0:
            print('No')
            return
        
    print('Yes')
    for s in ans:
        print(s)

main()


N, A, B, C = map(int, input().split())
dt = {'AB': (0, 1), 'AC': (0, 2), 'BC': (1, 2)}
Q = [dt[input()] for _ in range(N)]


class Game:
    def __init__(self, ABC):
        self.ABC = ABC
        self.ds = {0: 'A', 1: 'B', 2: 'C'}
        self.ans = []

    def add_q0(self, q0, q1):
        self.ans.append(self.ds[q0])
        self.ABC[q0] += 1
        self.ABC[q1] -= 1

    def add_q1(self, q0, q1):
        self.ans.append(self.ds[q1])
        self.ABC[q0] -= 1
        self.ABC[q1] += 1


def solve1(ABC):
    G = Game(ABC)
    for q0, q1 in Q:
        if G.ABC[q0] == G.ABC[q1] == 0:
            print('No')
            return
        elif G.ABC[q0] == 0:
            G.add_q0(q0, q1)
        else:
            G.add_q1(q0, q1)
    print('Yes')
    print(*G.ans, sep='\n')


def solve2(ABC):
    G = Game(ABC)
    for i, (q0, q1) in enumerate(Q):
        if G.ABC[q0] == G.ABC[q1] == 0:
            print('No')
            return
        elif G.ABC[q0] == 0:
            G.add_q0(q0, q1)
        elif G.ABC[q1] == 0:
            G.add_q1(q0, q1)
        elif G.ABC[q0] == G.ABC[q1] == 1 and sum(ABC) == 2 and i < N - 1:
            if q0 in Q[i + 1]:
                G.add_q0(q0, q1)
            else:
                G.add_q1(q0, q1)
        else:
            # 余裕の無い方に足しておく
            if G.ABC[q0] <= G.ABC[q1]:
                G.add_q0(q0, q1)
            else:
                G.add_q1(q0, q1)
    print('Yes')
    print(*G.ans, sep='\n')


S = A + B + C
if S == 0:
    print('No')
elif S == 1:
    solve1([A, B, C])
else:
    solve2([A, B, C])


N, A, B, C = list(map(int, input().split()))
nums = [A, B, C]
steps = [input() for i in range(N)]
chars = ["A", "B", "C"]
operations = []
can_select = True
for i in range(N):
    s = steps[i]
    left_idx = chars.index(s[0])
    right_idx = chars.index(s[1])
    if (nums[left_idx] == 0 and nums[right_idx] == 0) or nums[left_idx] < 0 or nums[right_idx] < 0:
        can_select = False
        break
    elif nums[left_idx] == 1 and nums[right_idx] == 1 and i != N-1:
        if chars[left_idx] in list(steps[i + 1]):
            nums[left_idx] += 1
            nums[right_idx] -= 1
            operations.append(chars[left_idx])
        else:
            nums[left_idx] -= 1
            nums[right_idx] += 1
            operations.append(chars[right_idx])
    else:
        if nums[left_idx] < nums[right_idx]:
            nums[left_idx] += 1
            nums[right_idx] -= 1
            operations.append(chars[left_idx])
        else:
            nums[left_idx] -= 1
            nums[right_idx] += 1
            operations.append(chars[right_idx])
if can_select:
    print("Yes")
    for i in operations:
        print(i)
else:
    print("No")


def solve(writer):
    N, A, B, C = list(map(int, input().split()))
    variables = {
        'A': A,
        'B': B,
        'C': C
    }

    queries = (list(input()) for _ in range(N))

    buffer = list()

    for i in range(N):

        if not buffer:
            t1, t2 = next(queries)
        else:
            b = buffer.pop()
            if b == 'pass':
                continue
            else:
                t1, t2 = list(b)

        v1 = variables[t1]
        v2 = variables[t2]

        if v1 == v2 == 0:
            return False

        elif v1 == v2 == 1:
            if i == N-1:
                writer.append(t1)
                return True

            nt1, nt2 = next(queries)
            if len({t1, t2, nt1, nt2}) == 2:
                buffer.append('pass')
                writer.append(t1)
                writer.append(t2)
                continue

            if t1 in {nt1, nt2}:
                variables[t1] += 1
                variables[t2] -= 1
                writer.append(t1)
            else:
                variables[t1] -= 1
                variables[t2] += 1
                writer.append(t2)

            buffer.append(''.join([nt1, nt2]))

        elif v1 > v2:
            variables[t1] -= 1
            variables[t2] += 1
            writer.append(t2)
        elif v2 > v1:
            variables[t1] += 1
            variables[t2] -= 1
            writer.append(t1)
        else:
            variables[t1] += 1
            variables[t2] -= 1
            writer.append(t1)

    return True


def main():
    writer = list()
    ok = solve(writer)
    if ok:
        print('Yes')
        for w in writer:
            print(w)
    else:
        print('No')


def __starting_point():
    main()

__starting_point()

def main():
    n, a, b, c = map(int, input().split())
    s = [list(input()) for _ in range(n)]
    num = dict(A=a, B=b, C=c)
    t = a+b+c
    ans = []
    if t == 0:
        print("No")
        return
    if t == 1:
        for i in range(n):
            si = s[i]
            if num[si[0]] == 1:
                num[si[0]] -= 1
                num[si[1]] += 1
                ans.append(si[1])
            elif num[si[1]] == 1:
                num[si[0]] += 1
                num[si[1]] -= 1
                ans.append(si[0])
            else:
                print("No")
                return
        print("Yes")
        print("\n".join(ans))
        return
    for i in range(n-1):
        si = s[i]
        if num[si[0]] == 0 and num[si[1]] >= 1:
            num[si[0]] += 1
            num[si[1]] -= 1
            ans.append(si[0])
        elif num[si[1]] == 0 and num[si[0]] >= 1:
            num[si[0]] -= 1
            num[si[1]] += 1
            ans.append(si[1])
        elif num[si[0]] >= 1 and num[si[1]] >= 1:
            sin = s[i+1]
            if si[0] in sin:
                num[si[0]] += 1
                num[si[1]] -= 1
                ans.append(si[0])
            else:
                num[si[0]] -= 1
                num[si[1]] += 1
                ans.append(si[1])
        else:
            print("No")
            return
    if num[s[n-1][0]] >= 1:
        ans.append(s[n-1][1])
    elif num[s[n-1][1]] >= 1:
        ans.append(s[n-1][0])
    else:
        print("No")
        return
    print("Yes")
    print("\n".join(ans))
    return

def __starting_point():
    main()
__starting_point()

N,A,B,C=map(int,input().split())
l=[]
i=0;j=0

if A+B+C!=2:pass
else:
  s=[]
  while i<N:
    s.append(input())
    i+=1
  if (A==2 and s[0]=='BC') or (B==2 and s[0]=='AC') or (C==2 and s[0]=='AB'):
    print('No');return
  print('Yes')
  while j<N:
    if j<N and s[j]=='AB':
      if A==B==1:
        if j==N-1:print('A');return
        if j<N-1 and s[j+1]=='AB':A=2;B=0;print('A')
        elif s[j+1]=='BC':A=0;B=1;C=1;print('B\nC');j+=1
        else: A=1;B=0;C=1;print('A\nC');j+=1
      else:
        if A>B:print('B');A-=1;B+=1
        else:print('A');A+=1;B-=1
      j+=1
    if j<N and s[j]=='BC':
      if B==C==1:
        if j==N-1:print('B');return
        if j<N-1 and s[j+1]=='BC':B=2;C=0;print('B')
        elif s[j+1]=='AB':A=1;B=1;C=0;print('B\nA');j+=1
        else: A=1;B=0;C=1;print('C\nA');j+=1
#      elif B==C==0:print('No');return
      else:
        if B>C:print('C');B-=1;C+=1
        else: print('B');B+=1;C-=1
      j+=1
    if j<N and s[j]=='AC':
      if A==C==1:
        if j==N-1:print('A');return
        if j<N-1 and s[j+1]=='AC':A=2;C=0;print('A')
        elif s[j+1]=='AB':A=1;B=1;C=0;print('A\nB');j+=1
        else: A=0;B=1;C=1;print('C\nB');j+=1
#      elif A==C==0:print('No');return
      else:
        if A>C:print('C');A-=1;C+=1
        else:print('A');A+=1;C-=1
      j+=1
#    print(j,A,B,C)
if A+B+C==2:return

#  if s=='AB':
#    if AB==0:
#      if A==0:A==1;B==0
#print(A+B+C);return
for i in range(N):
  s=input()
#  print(A,B,C,s)
  if s=='AB':
    if A>B:A-=1;B+=1;l.append('B')
    else:A+=1;B-=1;l.append('A')
  if s=='BC':
    if B>C:B-=1;C+=1;l.append('C')
    else:B+=1;C-=1;l.append('B')
  if s=='AC':
    if C>A:C-=1;A+=1;l.append('A')
    else:C+=1;A-=1;l.append('C')
  if A<0 or B<0 or C<0:print('No');return
#print(A,B,C)
print('Yes')
print(*l,sep='\n')

N,A,B,C=map(int,input().split())
l=[]
i=0;j=0

if A+B+C!=2:pass
else:
  s=[]
  while i<N:
    s.append(input())
    i+=1
  if (A==2 and s[0]=='BC') or (B==2 and s[0]=='AC') or (C==2 and s[0]=='AB'):
    print('No');return
  print('Yes')
  while j<N:
    if j<N and s[j]=='AB':
      if A==B==1:
        if j==N-1:print('A');return
        if j<N-1 and s[j+1]=='AB':A=2;B=0;print('A')
        elif s[j+1]=='BC':A=0;B=1;C=1;print('B\nC');j+=1
        else: A=1;B=0;C=1;print('A\nC');j+=1
      else:
        if A>B:print('B');A-=1;B+=1
        else:print('A');A+=1;B-=1
      j+=1
    if j<N and s[j]=='BC':
      if B==C==1:
        if j==N-1:print('B');return
        if j<N-1 and s[j+1]=='BC':B=2;C=0;print('B')
        elif s[j+1]=='AB':A=1;B=1;C=0;print('B\nA');j+=1
        else: A=1;B=0;C=1;print('C\nA');j+=1
      else:
        if B>C:print('C');B-=1;C+=1
        else: print('B');B+=1;C-=1
      j+=1
    if j<N and s[j]=='AC':
      if A==C==1:
        if j==N-1:print('A');return
        if j<N-1 and s[j+1]=='AC':A=2;C=0;print('A')
        elif s[j+1]=='AB':A=1;B=1;C=0;print('A\nB');j+=1
        else: A=0;B=1;C=1;print('C\nB');j+=1
      else:
        if A>C:print('C');A-=1;C+=1
        else:print('A');A+=1;C-=1
      j+=1
if A+B+C==2:return

for i in range(N):
  s=input()
  if s=='AB':
    if A>B:A-=1;B+=1;l.append('B')
    else:A+=1;B-=1;l.append('A')
  if s=='BC':
    if B>C:B-=1;C+=1;l.append('C')
    else:B+=1;C-=1;l.append('B')
  if s=='AC':
    if C>A:C-=1;A+=1;l.append('A')
    else:C+=1;A-=1;l.append('C')
  if A<0 or B<0 or C<0:print('No');return
print('Yes')
print(*l,sep='\n')

N, A, B, C = map(int, input().split())
s = ["" for i in range(N)]
for i in range(N):
    s[i] = input()
   
valid = True
ans = []
all_sum = A + B + C
if all_sum >= 3:
    for op in s:
        if op == "AB":
            if A > B:
                A -= 1
                B += 1
                ans.append("B")
            else:
                A += 1
                B -= 1
                ans.append("A")
        elif op == "BC":
            if B > C:
                B -= 1
                C += 1
                ans.append("C")
            else:
                B += 1
                C -= 1
                ans.append("B")
        else:
            if A > C:
                A -= 1
                C += 1
                ans.append("C")
            else:
                A += 1
                C -= 1
                ans.append("A")
        if A < 0 or B < 0 or C < 0:
            valid = False
            break
        
    if valid:
        print("Yes")
        for c in ans:
            print(c)
    else:
        print("No")
else:
    for i in range(N):
        op = s[i]
        if op == "AB":
            if A > B:
                A -= 1
                B += 1
                ans.append("B")
            elif A < B:
                A += 1
                B -= 1
                ans.append("A")
            else:
                if i != N - 1 and "A" in s[i + 1]:
                    A += 1
                    B -= 1
                    ans.append("A")
                else:
                    A -= 1
                    B += 1
                    ans.append("B")
        elif op == "AC":
            if A > C:
                A -= 1
                C += 1
                ans.append("C")
            elif A < C:
                A += 1
                C -= 1
                ans.append("A")
            else:
                if i != N - 1 and "A" in s[i + 1]:
                    A += 1
                    C -= 1
                    ans.append("A")
                else:
                    A -= 1
                    C += 1
                    ans.append("C")
        else:
            if B > C:
                B -= 1
                C += 1
                ans.append("C")
            elif B < C:
                B += 1
                C -= 1
                ans.append("B")
            else:
                if i != N - 1 and "B" in s[i + 1]:
                    B += 1
                    C -= 1
                    ans.append("B")
                else:
                    B -= 1
                    C += 1
                    ans.append("C")
        if A < 0 or B < 0 or C < 0:
            valid = False
            break
    if valid:
        print("Yes")
        for c in ans:
            print(c)
    else:
        print("No")

n,a,b,c=list(map(int,input().split()))
s=[input() for _ in range(n)]
ans=[]
d={'A':a,'B':b,'C':c}
for i in range(n):
  x,y=list(s[i])
  if d[x]==0 and d[y]==0:
    print('No')
    return
  elif d[x]==1 and d[y]==1 and i<n-1:
    if x in s[i+1]:
      d[x]+=1
      d[y]-=1
      ans.append(x)
    else:
      d[x]-=1
      d[y]+=1
      ans.append(y)
  elif set((d[x],d[y]))==set((1,0)):
    d[x],d[y]=d[y],d[x]
    ans.append(x if d[x]>d[y] else y)
  elif d[x]>=d[y]:
    d[y]+=1
    d[x]-=1
    ans.append(y)
  else:
    d[y]-=1
    d[x]+=1
    ans.append(x)
print('Yes')
for ansi in ans:
  print(ansi)


import sys
input = sys.stdin.readline
N,A,B,C = map(int,input().split())
S = [input().rstrip() for i in range(N)]

if A==B==C==0:
    print('No')
    return

if A+B+C == 1:
    ans = []
    for s in S:
        if (s=='AB' and A+B==0) or (s=='AC' and A+C==0) or (s=='BC' and B+C==0):
            print('No')
            return
        if s=='AB':
            if A<B:
                ans.append('A')
            else:
                ans.append('B')
            A,B = B,A
        if s=='AC':
            if A<C:
                ans.append('A')
            else:
                ans.append('C')
            A,C = C,A
        if s=='BC':
            if B<C:
                ans.append('B')
            else:
                ans.append('C')
            B,C = C,B
    print('Yes')
    print(*ans, sep='\n')

else:
    ans = []
    for i,s in enumerate(S):
        if (s=='AB' and A+B==0) or (s=='AC' and A+C==0) or (s=='BC' and B+C==0):
            print('No')
            return
        if s=='AB':
            if A==0:
                ans.append('A')
                A += 1
                B -= 1
            elif B==0:
                ans.append('B')
                B += 1
                A -= 1
            elif A==B==1:
                if i == N-1 or C > 0 or S[i+1]=='AB':
                    ans.append('A')
                    A += 1
                    B -= 1
                elif S[i+1]=='AC':
                    ans.append('A')
                    A += 1
                    B -= 1
                else:
                    ans.append('B')
                    B += 1
                    A -= 1
            elif A < B:
                ans.append('A')
                A += 1
                B -= 1
            else:
                ans.append('B')
                B += 1
                A -= 1
        if s=='AC':
            if A==0:
                ans.append('A')
                A += 1
                C -= 1
            elif C==0:
                ans.append('C')
                C += 1
                A -= 1
            elif A==C==1:
                if i == N-1 or B > 0 or S[i+1]=='AC':
                    ans.append('C')
                    C += 1
                    A -= 1
                elif S[i+1]=='AB':
                    ans.append('A')
                    A += 1
                    C -= 1
                else:
                    ans.append('C')
                    C += 1
                    A -= 1
            elif C < A:
                ans.append('C')
                C += 1
                A -= 1
            else:
                ans.append('A')
                A += 1
                C -= 1
        if s=='BC':
            if B==0:
                ans.append('B')
                B += 1
                C -= 1
            elif C==0:
                ans.append('C')
                C += 1
                B -= 1
            elif B==C==1:
                if i == N-1 or A > 0 or S[i+1]=='BC':
                    ans.append('B')
                    B += 1
                    C -= 1
                elif S[i+1]=='AB':
                    ans.append('B')
                    B += 1
                    C -= 1
                else:
                    ans.append('C')
                    C += 1
                    B -= 1
            elif B < C:
                ans.append('B')
                B += 1
                C -= 1
            else:
                ans.append('C')
                C += 1
                B -= 1
    print('Yes')
    print(*ans, sep='\n')

N,A,B,C = list(map(int, input().split()))
X = [A,B,C]
ANS = []

flg = True
D = []
pat = {'AB':[0,1], 'BC':[1,2], 'AC':[0,2]}

for i in range(N):
  l = input()
  D.append(pat[l])
  
for i in range(N):
  ai, bi = D[i]
  an, bn = D[i+1] if i < N-1 else [0,1] # nanndemoyoi

  if X[ai] == 0 and X[bi] == 0:
    flg = False
    break
  elif X[ai] == 0:
    ANS.append(ai)
    X[ai] += 1
    X[bi] -= 1
  elif X[bi] == 0:
    ANS.append(bi)
    X[bi] += 1
    X[ai] -= 1
  else:
    if ai == an or ai == bn:
      pl, mi = ai, bi
    else:
      pl, mi = bi, ai
    # 先読みで使う方
    ANS.append(pl)
    X[pl] += 1
    X[mi] -= 1
      
if not flg:
  print('No')
else:
  print('Yes')
  dd = {0:'A', 1:'B', 2:'C'}
  for ans in ANS:
    print((dd[ans]))
    



n,a,b,c=map(int, input().split(' '))
# print(n,a,b,c)
left=[a,b,c]
ans=[]
prev=(-1,-1)
for i in range(0,n):
    s=input()
    # print(s)
    x = {'A':0,'B':1,'C':2}[s[0]]
    y = {'A':0,'B':1,'C':2}[s[1]]
    if left[x]==left[y]==0:
        x0,y0=prev
        if x0!=-1:
            left[x0]-=1
            left[y0]+=1
            if left[x0]==0:
                ans=[]
                break
            left[x0]-=1
            left[y0]+=1
            ans[len(ans)-1]="ABC"[y0]
        else:
            ans=[]
            break
    if left[x]>left[y]:
        x,y=y,x
    left[x]+=1
    left[y]-=1
    ans.append("ABC"[x])
    prev=(x,y)

if len(ans)==0:
    print("No")
else:
    print("Yes")
    for x in ans:
        print(x)

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def calc(x, y):
        cnt[x] += 1
        cnt[y] -= 1
        res.append(S[x])

    n, *cnt = map(int, input().split())
    S = "ABC"
    query = []
    for _ in range(n):
        s = input().rstrip()
        a = 0 if s == "AB" else 0 if s == "AC" else 1
        b = 1 if s == "AB" else 2 if s == "AC" else 2
        query.append((a, b))
    query.append((None, None))

    res = []
    for i in range(n):
        a, b = query[i]
        if cnt[a] == cnt[b] == 0:
            print("No")
            return
        elif cnt[a] == 0:
            calc(a, b)
        elif cnt[b] == 0:
            calc(b, a)
        else:
            next_a, next_b = query[i + 1]
            if a == next_a or a == next_b:
                calc(a, b)
            else:
                calc(b, a)
    print("Yes")
    print(*res, sep="\n")


def __starting_point():
    resolve()

__starting_point()

def main():
    N,A,B,C=list(map(int,input().split()))
    d={'AB':(0,1),'AC':(0,2),'BC':(1,2)}
    s=[d[input()] for _ in range(N)]
    abc=[A,B,C]
    ABC='ABC'
    ans=[]
    for i in range(N):
        x,y=s[i]
        # 強制終了
        if abc[x] == abc[y] == 0:
            print('No')
            return
        if abc[x] == abc[y] == 1:
            # 最後の要素 or 次に今回選ぶ可能性があるものがあるかどうか
            if (i == N-1) or (x in s[i+1]):
                ans.append(ABC[x])
                abc[x]+=1
                abc[y]-=1
            else:
                ans.append(ABC[y])
                abc[x]-=1
                abc[y]+=1
        # 2数の和が1 or 3以上の場合は大きい方をインクリメント, 小さい方をデクリメントする.
        # 2数が同じ場合には 後半の文字に対応する番号を優先する.
        else:
            if abc[x] > abc[y]:
                ans.append(ABC[y])
                abc[x]-=1
                abc[y]+=1
            else:
                ans.append(ABC[x])
                abc[x]+=1
                abc[y]-=1
    print('Yes')
    for a in ans:
        print(a)

main()


N, A, B, C = map(int,input().split())
ans = []
flag = True
cnt = 0
while True:
  cnt += 1
  if cnt > N:
    break
  s = input()
  if s == 'AB':
    if A == B == 0:
      flag = False
      break
    elif A == B == 1 and C == 0:
      if cnt == N:
        ans.append('A')
        break
      else:
        cnt += 1
        s = input()
        if s == 'AB':
          ans.append('A')
          ans.append('B')
          continue
        elif s == 'AC':
          ans.append('A')
          ans.append('C')
          B -= 1
          C += 1
          continue
        else:
          ans.append('B')
          ans.append('C')
          A -= 1
          C += 1
          continue
    elif A >= B:
      A -= 1
      B += 1
      ans.append('B')
      continue
    else:
      B -= 1
      A += 1
      ans.append('A')
      continue
  elif s == 'BC':
    if B == C == 0:
      flag = False
      break
    elif B == C == 1 and A == 0:
      if cnt == N:
        ans.append('B')
        break
      else:
        cnt += 1
        s = input()
        if s == 'BC':
          ans.append('B')
          ans.append('C')
          continue
        elif s == 'AB':
          ans.append('B')
          ans.append('A')
          C -= 1
          A += 1
          continue
        else:
          ans.append('C')
          ans.append('A')
          B -= 1
          A += 1
          continue
    elif B >= C:
      B -= 1
      C += 1
      ans.append('C')
      continue
    else:
      C -= 1
      B += 1
      ans.append('B')
      continue 
  else:
    if C == A == 0:
      flag = False
      break
    elif C == A == 1 and B == 0:
      if cnt == N:
        ans.append('C')
        break
      else:
        cnt += 1
        s = input()
        if s == 'AC':
          ans.append('C')
          ans.append('A')
          continue
        elif s == 'BC':
          ans.append('C')
          ans.append('B')
          A -= 1
          B += 1
          continue
        else:
          ans.append('A')
          ans.append('B')
          C -= 1
          B += 1
          continue
    elif A >= C:
      A -= 1
      C += 1
      ans.append('C')
      continue
    else:
      C -= 1
      A += 1
      ans.append('A')
      continue
if flag:
  print('Yes')
  for item in ans:
    print(item)
else:
  print('No')

n, a, b, c = map(int, input().split())
q = [input() for i in range(n)]
ab, ac, bc = "AB", "AC", "BC"
ans = []
for i in range(n):
  
  if((q[i] == ab and a == b == 0)
  or (q[i] == ac and a == c == 0) 
  or (q[i] == bc and b == c == 0)):
      print("No")
      return
      
  elif(q[i] == ab and [a, b, c] == [1, 1, 0] and i != n - 1):
    if q[i+1] == ac: 
      a, b = a+1, b-1
      ans.append("A")
    else:
      a, b = a-1, b+1
      ans.append("B")     
      
  elif(q[i] == ac and [a, b, c] == [1, 0, 1] and i != n - 1):
    if q[i+1] == ab:
      a, c = a+1, c-1
      ans.append("A")
    else:
      a, c = a-1, c+1
      ans.append("C")
      
  elif(q[i] == bc and [a, b, c] == [0, 1, 1] and i != n - 1):
    if q[i+1] == ab:
      b, c = b+1, c-1
      ans.append("B")
    else:
      b, c = b-1, c+1
      ans.append("C")
      
  elif q[i] == ab:
    if a > b:
      a, b = a-1, b+1
      ans.append("B")
    else:
      a, b = a+1, b-1
      ans.append("A")
      
  elif q[i] == ac:
    if a > c:
      a, c = a-1, c+1
      ans.append("C")
    else:
      a, c = a+1, c-1
      ans.append("A")
      
  elif q[i] == bc:
    if b > c:
      b, c = b-1, c+1
      ans.append("C")
    else:
      b, c = b+1, c-1
      ans.append("B")

print("Yes")
for i in range(n):
  print(ans[i])

n,a,b,c=map(int,input().split())
s=[input() for _ in range(n)]
abc=[a,b,c]
d={'A':0,'B':1,'C':2}
dr={0:'A',1:'B',2:'C'}
ans=[]
for i,x in enumerate(s):
  x=[d[y] for y in list(x)]
  if abc[x[0]]==abc[x[1]]==1 and i<n-1:
    nx=[d[y] for y in list(s[i+1])]
    for j,y in enumerate(x):
      if y in nx:
        abc[y]+=1
        abc[x[(j+1)%2]]-=1
        ans.append(dr[y])
        break
  elif abc[x[0]]>abc[x[1]]:
    abc[x[1]]+=1
    abc[x[0]]-=1
    ans.append(dr[x[1]])
  else:
    abc[x[0]]+=1
    abc[x[1]]-=1
    ans.append(dr[x[0]])
  for y in abc:
    if y<0:
      print('No')
      return
  
print('Yes')
print(*ans,sep='\n')

def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    def stoidx(s):
        if s == 'AB':
            return (0, 1)
        elif s == 'BC':
            return (1, 2)
        else:
            return (0, 2)


    def answer(ans):
        print('Yes')
        for a in ans:
            print(a)

    def add_answer(x):
        if s[x[0]] > s[x[1]]:
            s[x[0]] -= 1
            s[x[1]] += 1
            ans.append(abc[x[1]])
        else:
            s[x[0]] += 1
            s[x[1]] -= 1
            ans.append(abc[x[0]])
        
    n, *s = list(map(int, input().split()))
    sl = []
    for _ in range(n):
        sl.append(stoidx(input()))
    abc = 'ABC'
    ans = []
    if sum(s) == 0:
        print('No')
        return

    elif sum(s) == 1:
        for x in sl:
            if s[x[0]] == 0 and s[x[1]] == 0:
                print('No')
                return
            add_answer(x)

    else:
        for i, x in enumerate(sl):
            if s[x[0]] == 0 and s[x[1]] == 0:
                print('No')
                return
                
            if i < n-1 and s[x[0]] == 1 and s[x[1]] == 1:
                nx = sl[i+1]
                if x != nx and sum(s)==2:
                    if x[0] in nx:
                        s[x[0]] += 1
                        s[x[1]] -= 1
                        ans.append(abc[x[0]])
                    else:
                        s[x[0]] -= 1
                        s[x[1]] += 1
                        ans.append(abc[x[1]])
                    continue
            add_answer(x)
    answer(ans)


def __starting_point():
    main()

__starting_point()

n, a, b, c = map(int, input().split())
A = [a, b, c]
D = {'AB': 0, 'BC': 1, 'AC': 2}
S = [input() for i in range(n)]
S.append('AB')
X = []
for i in range(n):
    x, y = D[S[i]], (D[S[i]] + 1) % 3
    if A[x] == 0 and A[y] == 0:
        print('No')
        return
    if A[x] < A[y]:
        A[x], A[y] = A[x] + 1, A[y] - 1
        X.append('ABC'[x])
    elif A[x] > A[y]:
        A[x], A[y] = A[x] - 1, A[y] + 1
        X.append('ABC'[y])
    else:
        x1, y1 = D[S[i + 1]], (D[S[i + 1]] + 1) % 3
        if x == y1:
            A[x], A[y] = A[x] + 1, A[y] - 1
            X.append('ABC'[x])
        else:
            A[x], A[y] = A[x] - 1, A[y] + 1
            X.append('ABC'[y])
print('Yes')
print(*X, sep='\n')


n,a,b,c=list(map(int,input().split()))
l=[]
for i in range(0,n):
    s=input()
    l.append(s)
final=[]
for i in range(0,len(l)):
    if l[i]=='AB':
        if a>b:
            b+=1
            a-=1
            final.append('B')
        elif a<b:
            b-=1
            a+=1
            final.append('A')
        else:
            if a==0:
                print('No')
                break
            else:
                if i!=len(l)-1:
                    if l[i+1]=='AB':
                        a+=1
                        b-=1
                        final.append('A')
                    elif l[i+1]=='AC':
                        a+=1
                        b-=1
                        final.append('A')
                    else:
                        a-=1
                        b+=1
                        final.append('B')
                else:
                    a-=1
                    b+=1
                    final.append('B')
    elif l[i]=='AC':
        if a>c:
            c+=1
            a-=1
            final.append('C')
        elif a<c:
            c-=1
            a+=1
            final.append('A')
        else:
            if a==0:
                print('No')
                break
            else:
                if i!=len(l)-1:
                    if l[i+1]=='AB':
                        a+=1
                        c-=1
                        final.append('A')
                    elif l[i+1]=='AC':
                        a+=1
                        c-=1
                        final.append('A')
                    else:
                        a-=1
                        c+=1
                        final.append('C')
                else:
                    a-=1
                    c+=1
                    final.append('C')
    else:
        if b>c:
            c+=1
            b-=1
            final.append('C')
        elif b<c:
            c-=1
            b+=1
            final.append('B')
        else:
            if b==0:
                print('No')
                break
            else:
                if i!=len(l)-1:
                    if l[i+1]=='AB':
                        b+=1
                        c-=1
                        final.append('B')
                    elif l[i+1]=='BC':
                        b+=1
                        c-=1
                        final.append('B')
                    else:
                        b-=1
                        c+=1
                        final.append('C')
                else:
                    b-=1
                    c+=1
                    final.append('C')
else:
    print('Yes')
    for i in range(0,len(final)):
        print((final[i]))


import numpy as np
def resolve():
    N,A,B,C = map(int,input().split())
    Nlist = []
    YesOrNo = True
    ABC = str(input())
    for i in range(N):
        ABC_old = ABC
        if i < N-1:
            ABC = str(input())

        if ABC_old == "AB":
            if ABC == "AC":
                add1 = np.sign(B - A + 0.1)
            else:
                add1 = np.sign(B - A - 0.1)

            if add1 < 0:
                Nlist.append("B")
            else:
                Nlist.append("A")
            A = A + add1
            B = B - add1
            if A < 0 or B < 0:
                YesOrNo = False
                print('No')
                break
        
        if ABC_old == "AC":
            if ABC == "AB":
                add1 = np.sign(C - A + 0.1)
            else:
                add1 = np.sign(C - A - 0.1)

            if add1 < 0:
                Nlist.append("C")
            else:
                Nlist.append("A")
            A = A + add1
            C = C - add1
            if A < 0 or C < 0:
                YesOrNo = False
                print('No')
                break
        
        if ABC_old == "BC":
            if ABC == "AB":
                add1 = np.sign(C - B + 0.1)
            else:
                add1 = np.sign(C - B - 0.1)

            if add1 < 0:
                Nlist.append("C")
            else:
                Nlist.append("B")
            B = B + add1
            C = C - add1
            if B < 0 or C < 0:
                YesOrNo = False
                print('No')
                break

    if YesOrNo:
        print("Yes")
        s_Nlist = '\n'.join(Nlist)
        print(s_Nlist)
resolve()

import sys
sys.setrecursionlimit(10 ** 5 + 10)

N, A, B, C = [int(i) for i in input().split()]

ans = list()
l = list()

for n in range(N):
    l.append(input())

def dfs(i, a, b, c):
    if i == N:
        return True

    ss = l[i]
    if ss == 'AB':
        if a == 0 and b == 0:
            return False
        if b > 0 and dfs(i + 1, a + 1, b - 1, c):
            ans.append('A')
            return True
        if a > 0 and dfs(i + 1, a - 1, b + 1, c):
            ans.append('B')
            return True
    if ss == 'AC':
        if a == 0 and c == 0:
            return False
        if c > 0 and dfs(i + 1, a + 1, b, c - 1):
            ans.append('A')
            return True
        if a > 0 and dfs(i + 1, a - 1, b, c + 1):
            ans.append('C')
            return True
    if ss == 'BC':
        if b == 0 and c == 0:
            return False
        if c > 0 and dfs(i + 1, a, b + 1, c - 1):
            ans.append('B')
            return True
        if b > 0 and dfs(i + 1, a, b - 1, c + 1):
            ans.append('C')
            return True
    return False

dfs(0, A, B, C)

if len(ans) > 0:
    print('Yes')
    for x in reversed(ans):
        print(x)
else:
    print('No')

def solve(A, B, C, S):
    N = len(S)
    abc = [A, B, C]
    path = []
    for si in range(N - 1):
        i, j = S[si]
        if abc[i] == abc[j] == 0:
            print('No')
            return
        if abc[i] == 0:
            path.append('ABC'[i])
            abc[i] += 1
            abc[j] -= 1
            continue
        elif abc[j] == 0:
            path.append('ABC'[j])
            abc[j] += 1
            abc[i] -= 1
            continue

        i2, j2 = S[si + 1]
        if not (abc[j] - 1 == 0 and abc[3 - i - j] == 0 and {i2, j2} == {3-i-j, j}):
            path.append('ABC'[i])
            abc[i] += 1
            abc[j] -= 1
            continue
        if not (abc[i] - 1 == 0 and abc[3 - i - j] == 0 and {i2, j2} == {3-i-j, i}):
            path.append('ABC'[j])
            abc[j] += 1
            abc[i] -= 1
            continue

        if abc[i] <= abc[j]:
            path.append('ABC'[i])
            abc[i] += 1
            abc[j] -=1
        else:
            path.append('ABC'[j])
            abc[j] += 1
            abc[i] -=1

    i, j = S[N - 1]
    if abc[i] == abc[j] == 0:
        print('No')
        return
    if abc[i] == 0:
        path.append('ABC'[i])
    else:
        path.append('ABC'[j])

    print('Yes')
    for c in path:
        print(c)


N, A, B, C = map(int, input().split())
S = []
for _ in range(N):
    s = input()
    S.append({'AB': (0, 1), 'AC': (0, 2), 'BC': (1, 2)}[s])
solve(A, B, C, S)

import sys
input = sys.stdin.readline

n, a, b, c = map(int, input().split())
d = {"A": a, "B": b, "C": c}
pl = [input() for _ in range(n)]
res = []
for i in range(n):
    p = pl[i]
    if d[p[0]] == d[p[1]] == 0:
        print("No");return
    elif d[p[0]] == 0:
        res.append(p[0])
        d[p[0]] += 1
        d[p[1]] -= 1
    elif d[p[1]] == 0:
        res.append(p[1])
        d[p[0]] -= 1
        d[p[1]] += 1
    elif i == n - 1:
        res.append(p[0])
    elif p[0] in pl[i + 1]:
        res.append(p[0])
        d[p[0]] += 1
        d[p[1]] -= 1
    else:
        res.append(p[1])
        d[p[0]] -= 1
        d[p[1]] += 1

print("Yes")
for p in res:
    print(p)

import sys

def func(op, val):
    target = []

    for i, o in enumerate(op):
        if sum([val[k] for k in o]) == 0:
            return []
        k0 = o[0]
        k1 = o[1]
        if val[k0] == 0:
            p,m = k0,k1
        elif val[k1] == 0:
            p,m = k1,k0
        elif i < len(op)-1 and k1 in op[i+1]:
            p,m = k1,k0
        else:
            p,m = k0,k1
        val[p] += 1
        val[m] -= 1
        target.append(p)
    return target

n,a,b,c = [int(x) for x in input().split()]
operation = [sys.stdin.readline().strip() for _ in range(n)]
val = {'A':a, 'B':b, 'C':c}

target = func(operation,val)

if len(target) == 0:
    print("No")
else:
    print("Yes")
    for t in target:
        print(t)

# 実際にシミュレーションしていく方針で解く
N, A, B, C = list(map(int, input().split()))
d = {}
d["A"] = A
d["B"] = B
d["C"] = C
S = [input() for _ in range(N)]
ans = []
for i in range(N):
    s = S[i]
    if s == "AB":
        if d["A"] > d["B"]:
            d["A"] -= 1
            d["B"] += 1
            ans.append("B")
        elif d["A"] < d["B"]:
            d["B"] -= 1
            d["A"] += 1
            ans.append("A")
        else:  # 同じ場合
            if d["A"] == d["B"] == 0:
                print("No")
                return
            if N > i+1:
                if "A" in S[i+1]:
                    d["B"] -= 1
                    d["A"] += 1
                    ans.append("A")
                elif "B" in S[i+1]:
                    d["A"] -= 1
                    d["B"] += 1
                    ans.append("B")
                else:
                    d["A"] -= 1
                    d["B"] += 1
                    ans.append("B")
            else:
                if d["A"] > 0:
                    ans.append("A")
                elif d["B"] > 0:
                    ans.append("B")

    if s == "AC":
        if d["A"] > d["C"]:
            d["A"] -= 1
            d["C"] += 1
            ans.append("C")
        elif d["A"] < d["C"]:
            d["C"] -= 1
            d["A"] += 1
            ans.append("A")
        else:
            if d["A"] == d["C"] == 0:
                print("No")
                return
            if N > i+1:
                if "A" in S[i+1]:
                    d["C"] -= 1
                    d["A"] += 1
                    ans.append("A")
                elif "C" in S[i+1]:
                    d["A"] -= 1
                    d["C"] += 1
                    ans.append("C")
                else:
                    d["A"] -= 1
                    d["C"] += 1
                    ans.append("C")
            else:
                if d["A"] > 0:
                    ans.append("A")
                elif d["C"] > 0:
                    ans.append("C")

    if s == "BC":
        if d["B"] > d["C"]:
            d["B"] -= 1
            d["C"] += 1
            ans.append("C")
        elif d["B"] < d["C"]:
            d["C"] -= 1
            d["B"] += 1
            ans.append("B")
        else:
            if d["B"] == d["C"] == 0:
                print("No")
                return
            if N > i+1:
                if "B" in S[i+1]:
                    d["C"] -= 1
                    d["B"] += 1
                    ans.append("B")
                elif "C" in S[i+1]:
                    d["B"] -= 1
                    d["C"] += 1
                    ans.append("C")
                else:
                    d["B"] -= 1
                    d["C"] += 1
                    ans.append("C")
            else:
                if d["B"] > 0:
                    ans.append("B")
                elif d["C"] > 0:
                    ans.append("C")

    if -1 in list(d.values()):
        print("No")
        return

print("Yes")
for a in ans:
    print(a)


n,a,b,c=list(map(int,input().split()))
if a+b+c==0:
    print("No")
elif a+b+c==1:
    d=[]
    for i in range(n):
        s=input()
        if s=="AB":
            if a+b==0:
                print("No")
                return
            else:
                if a==0:
                    d.append("A")
                else:
                    d.append("B")
                a,b=b,a
        if s=="BC":
            if c+b==0:
                print("No")
                return
            else:
                if b==0:
                    d.append("B")
                else:
                    d.append("C")
                c,b=b,c
        if s=="AC":
            if a+c==0:
                print("No")
                return
            else:
                if a==0:
                    d.append("A")
                else:
                    d.append("C")
                a,c=c,a 
    print("Yes")
    for i in d:
        print(i)
else:
    d=[]
    s=[input()for i in range(n)]+["AB"]
    for i in range(n):
        if s[i]=="AB":
            if a+b==0:
                print("No")
                return
            if a+b+c==2 and a==1 and b==1 and s[i+1]!=s[i]:
                if s[i+1]=="AC":
                    d.append("A")
                    a+=1
                    b-=1
                else:
                    d.append("B")
                    b+=1
                    a-=1
            elif a<b:
                d.append("A")
                a+=1
                b-=1
            else:
                d.append("B")
                b+=1
                a-=1
        elif s[i]=="BC":
            if c+b==0:
                print("No")
                return
            if a+b+c==2 and c==1 and b==1 and s[i+1]!=s[i]:
                if s[i+1]=="AB":
                    d.append("B")
                    c-=1
                    b+=1
                else:
                    d.append("C")
                    c+=1
                    b-=1
            elif b<c:
                d.append("B")
                b+=1
                c-=1
            else:
                d.append("C")
                c+=1
                b-=1
        elif s[i]=="AC":
            if c+a==0:
                print("No")
                return
            if a+b+c==2 and c==1and a==1 and s[i+1]!=s[i]:
                if s[i+1]=="AB":
                    d.append("A")
                    a+=1
                    c-=1
                else:
                    d.append("C")
                    c+=1
                    a-=1
            elif a<c:
                d.append("A")
                a+=1
                c-=1
            else:
                d.append("C")
                c+=1
                a-=1
    print("Yes")
    for i in d:
        print(i)


def main():
    #input
    N, A, B, C = map(int, input().split())
    s = [""] * (N+1)
    for i in range(N):
        s[i] = str(input())

    #i(0, 1, ..., N-1)回目の施行が始まる前のA, B, Cの個数を
    #a[i], b[i], c[i]とする。
    #i回目の施行で選ばれる変数をdp[i]とする。
    #output
    dp = [""] * N
    a, b, c = [0]*(N+1), [0]*(N+1), [0]*(N+1)
    a[0], b[0], c[0] = A, B, C

    #s[i]がABの時
    #   a[i] + b[i] == 0 の時続行不能
    #   a[i] == 1, b[i] == 0 の時 a[i+1] = a[i]-1, b[i+1] = b[i]+1
    #   a[i] == 0, b[i] == 1 の時 a[i+1] = a[i]+1, b[i+1] = b[i]-1
    #   a[i] == 1, b[i] == 1 の時
    #       最後のターンでなければs[i+1]を見て
    #           ABならばどちらでも良い
    #           BCならばa[i+1] = a[i]-1, b[i+1] = b[i]+1
    #           ACならばa[i+1] = a[i]+1, b[i+1] = b[i]-1
    #       最後のターンであればどちらでも良い
    #   a[i] > 1, b[i] > 1の時
    #       a[i] >= b[i]ならばa[i+1] = a[i]-1, b[i+1] = b[i]+1
    #       a[i] < b[i]ならばa[i+1] = a[i]+1, b[i+1] = b[i]-1

    for i in range(N):
        if s[i] == "AB":
            if a[i] + b[i] == 0:
                print("No")
                return
            elif a[i] == 1 and b[i] == 0:
                a[i+1] = a[i] - 1
                b[i+1] = b[i] + 1
                c[i+1] = c[i]
                dp[i] = "B"
            elif a[i] == 0 and b[i] == 1:
                a[i+1] = a[i] + 1
                b[i+1] = b[i] - 1
                c[i+1] = c[i]
                dp[i] = "A"
            elif a[i] == 0 and b[i] > 1:
                a[i+1] = a[i] + 1
                b[i+1] = b[i] - 1
                c[i+1] = c[i]
                dp[i] = "A"
            elif a[i] > 1 and b[i] == 0:
                a[i+1] = a[i] - 1
                b[i+1] = b[i] + 1
                c[i+1] = c[i]
                dp[i] = "B"
            elif a[i] == 1 and b[i] == 1:
                if s[i+1] == "":
                    a[i+1] = a[i] - 1
                    b[i+1] = b[i] + 1
                    c[i+1] = c[i]
                    dp[i] = "B"
                elif s[i+1] == "AB":
                    a[i+1] = a[i] + 1
                    b[i+1] = b[i] - 1
                    c[i+1] = c[i]
                    dp[i] = "A"
                elif s[i+1] == "BC":
                    a[i+1] = a[i] - 1
                    b[i+1] = b[i] + 1
                    c[i+1] = c[i]
                    dp[i] = "B"
                elif s[i+1] == "AC":
                    a[i+1] = a[i] + 1
                    b[i+1] = b[i] - 1
                    c[i+1] = c[i]
                    dp[i] = "A"
            elif a[i] == 1 and b[i] > 1:
                a[i+1] = a[i] + 1
                b[i+1] = b[i] - 1
                c[i+1] = c[i]
                dp[i] = "A"
            elif a[i] > 1 and b[i] == 1:
                a[i+1] = a[i] - 1
                b[i+1] = b[i] + 1
                c[i+1] = c[i]
                dp[i] = "B"
            elif a[i] > 1 and b[i] > 1:
                if a[i] >= b[i]:
                    a[i+1] = a[i] - 1
                    b[i+1] = b[i] + 1
                    c[i+1] = c[i]
                    dp[i] = "B"
                elif a[i] < b[i]:
                    a[i+1] = a[i] + 1
                    b[i+1] = b[i] - 1
                    c[i+1] = c[i]
                    dp[i] = "A"
    #ここまでで一段落。
        elif s[i] == "BC":
            if b[i] + c[i] == 0:
                print("No")
                return
            elif b[i] == 1 and c[i] == 0:
                b[i+1] = b[i] - 1
                c[i+1] = c[i] + 1
                a[i+1] = a[i]
                dp[i] = "C"
            elif b[i] == 0 and c[i] == 1:
                b[i+1] = b[i] + 1
                c[i+1] = c[i] - 1
                a[i+1] = a[i]
                dp[i] = "B"
            elif b[i] == 0 and c[i] > 1:
                b[i+1] = b[i] + 1
                c[i+1] = c[i] - 1
                a[i+1] = a[i]
                dp[i] = "B"
            elif b[i] > 1 and c[i] == 0:
                b[i+1] = b[i] - 1
                c[i+1] = c[i] + 1
                a[i+1] = a[i]
                dp[i] = "C"
            elif b[i] == 1 and c[i] == 1:
                if s[i+1] == "":
                    b[i+1] = b[i] - 1
                    c[i+1] = c[i] + 1
                    a[i+1] = a[i]
                    dp[i] = "C"
                elif s[i+1] == "BC":
                    b[i+1] = b[i] + 1
                    c[i+1] = c[i] - 1
                    a[i+1] = a[i]
                    dp[i] = "B"
                elif s[i+1] == "AC":
                    b[i+1] = b[i] - 1
                    c[i+1] = c[i] + 1
                    a[i+1] = a[i]
                    dp[i] = "C"
                elif s[i+1] == "AB":
                    b[i+1] = b[i] + 1
                    c[i+1] = c[i] - 1
                    a[i+1] = a[i]
                    dp[i] = "B"
            elif b[i] == 1 and c[i] > 1:
                b[i+1] = b[i] + 1
                c[i+1] = c[i] - 1
                a[i+1] = a[i]
                dp[i] = "B"
            elif b[i] > 1 and c[i] == 1:
                b[i+1] = b[i] - 1
                c[i+1] = c[i] + 1
                a[i+1] = a[i]
                dp[i] = "C"
            elif b[i] > 1 and c[i] > 1:
                if b[i] >= c[i]:
                    b[i+1] = b[i] - 1
                    c[i+1] = c[i] + 1
                    a[i+1] = a[i]
                    dp[i] = "C"
                elif b[i] < c[i]:
                    b[i+1] = b[i] + 1
                    c[i+1] = c[i] - 1
                    a[i+1] = a[i]
                    dp[i] = "B"
    #ここまででもう一段落。
        elif s[i] == "AC":
            if c[i] + a[i] == 0:
                print("No")
                return
            elif c[i] == 1 and a[i] == 0:
                c[i+1] = c[i] - 1
                a[i+1] = a[i] + 1
                b[i+1] = b[i]
                dp[i] = "A"
            elif c[i] == 0 and a[i] == 1:
                c[i+1] = c[i] + 1
                a[i+1] = a[i] - 1
                b[i+1] = b[i]
                dp[i] = "C"
            elif c[i] == 0 and a[i] > 1:
                c[i+1] = c[i] + 1
                a[i+1] = a[i] - 1
                b[i+1] = b[i]
                dp[i] = "C"
            elif c[i] > 1 and a[i] == 0:
                c[i+1] = c[i] - 1
                a[i+1] = a[i] + 1
                b[i+1] = b[i]
                dp[i] = "A"
            elif c[i] == 1 and a[i] == 1:
                if s[i+1] == "":
                    c[i+1] = c[i] - 1
                    a[i+1] = a[i] + 1
                    b[i+1] = b[i]
                    dp[i] = "A"
                elif s[i+1] == "AC":
                    c[i+1] = c[i] + 1
                    a[i+1] = a[i] - 1
                    b[i+1] = b[i]
                    dp[i] = "C"
                elif s[i+1] == "AB":
                    c[i+1] = c[i] - 1
                    a[i+1] = a[i] + 1
                    b[i+1] = b[i]
                    dp[i] = "A"
                elif s[i+1] == "BC":
                    c[i+1] = c[i] + 1
                    a[i+1] = a[i] - 1
                    b[i+1] = b[i]
                    dp[i] = "C"
            elif c[i] == 1 and a[i] > 1:
                c[i+1] = c[i] + 1
                a[i+1] = a[i] - 1
                b[i+1] = b[i]
                dp[i] = "C"
            elif c[i] > 1 and a[i] == 1:
                c[i+1] = c[i] - 1
                a[i+1] = a[i] + 1
                b[i+1] = b[i]
                dp[i] = "A"
            elif c[i] > 1 and a[i] > 1:
                if c[i] >= a[i]:
                    c[i+1] = c[i] - 1
                    a[i+1] = a[i] + 1
                    b[i+1] = b[i]
                    dp[i] = "A"
                elif c[i] < a[i]:
                    c[i+1] = c[i] + 1
                    a[i+1] = a[i] - 1
                    b[i+1] = b[i]
                    dp[i] = "C"

    print("Yes")
    for v in dp:
        print(v)

def __starting_point():
    main()
__starting_point()

N, A, B, C = list(map(int, input().split()))
vars = {"A": A, "B": B, "C": C}
sum_ABC = A+B+C
S = [input() for _ in range(N)]
Ans = []
for s, s_next in zip(S, S[1:]):
    if vars[s[0]] > vars[s[1]] or (vars[s[0]]==vars[s[1]] and s[1] in s_next):
        Ans.append(s[1])
        vars[s[1]] += 1
        vars[s[0]] -= 1
    else:# vars[s[0]] < vars[s[1]]:
        Ans.append(s[0])
        vars[s[0]] += 1
        vars[s[1]] -= 1
    if vars[s[0]] < 0 or vars[s[1]] < 0:
        print("No")
        return
s = S[-1]
if vars[s[0]] > vars[s[1]]:
    Ans.append(s[1])
    vars[s[1]] += 1
    vars[s[0]] -= 1
else:
    Ans.append(s[0])
    vars[s[0]] += 1
    vars[s[1]] -= 1
if vars[s[0]] < 0 or vars[s[1]] < 0:
    print("No")
    return
print("Yes")
print(("\n".join(Ans)))


import sys
n, a, b, c = map(int, input().split())
s = []
for _ in range(n):
    s.append(input())
    
ans =[]
for i in range(n):
    if s[i] == "AB":
        if a == b == 1 and i < n-1:
            if s[i+1] == "AC":
                a += 1
                b -= 1
                ans.append("A")
            else:
                a -= 1
                b+= 1
                ans.append("B")
        else:
            if min(a, b) == a:
                a += 1
                b -= 1
                ans.append("A")
            else:
                a -= 1
                b+= 1
                ans.append("B")
    elif s[i] == "BC":
        if c == b == 1 and i < n-1:
            if s[i+1] == "AB":
                b += 1
                c -= 1
                ans.append("B")
            else:
                b -= 1
                c+= 1
                ans.append("C")
        else:
            if min(c, b) ==b:
                b += 1
                c -= 1
                ans.append("B")
            else:
                b -= 1
                c+= 1
                ans.append("C")
    else:
        if c == a == 1 and i < n-1:
            if s[i+1] == "BC":
                c += 1
                a -= 1
                ans.append("C")
            else:
                a += 1
                c-= 1
                ans.append("A")
        else:
            if min(c, a) == c:
                c += 1
                a -= 1
                ans.append("C")
            else:
                c -= 1
                a += 1
                ans.append("A")
    if min(a, b, c) < 0:
        print("No")
        return

print("Yes")
print("\n".join(ans))

def main():
    N, A, B, C = list(map(int, input().split(' ')))
    S = [input() for _ in range(N)]
    D = {
        'AB': A + B,
        'BC': B + C,
        'AC': A + C
    }
    ans = list()
    for i, s in enumerate(S):
        if D[s] == 0:
            print('No')
            return
        if s == 'AB':
            if (D['BC'] < D['AC']) or \
                (i < N - 1 and S[i + 1] == 'BC' and D['BC'] == D['AC'] == 1):
                ans.append('B')
                D['BC'] += 1
                D['AC'] -= 1
            else:
                ans.append('A')
                D['BC'] -= 1
                D['AC'] += 1
        elif s == 'BC':
            if (D['AB'] < D['AC']) or \
                (i < N - 1 and S[i + 1] == 'AB' and D['AB'] == D['AC'] == 1):
                ans.append('B')
                D['AB'] += 1
                D['AC'] -= 1
            else:
                ans.append('C')
                D['AB'] -= 1
                D['AC'] += 1
        else:  # s == 'AC'
            if (D['AB'] < D['BC']) or \
                (i < N - 1 and S[i + 1] == 'AB' and D['AB'] == D['BC'] == 1):
                ans.append('A')
                D['AB'] += 1
                D['BC'] -= 1
            else:
                ans.append('C')
                D['AB'] -= 1
                D['BC'] += 1
    print('Yes')
    for a in ans:
        print(a)

def __starting_point():
    main()
__starting_point()

def abc(d, down_text, up_text):
    d[down_text] -= 1
    d[up_text] += 1


def main():
    n, a, b, c = map(int, input().split())
    ans_list = []
    dct = {"A": a, "B": b, "C": c}

    abc_list = [input() for _ in range(n)]
    abc_list.append('AB')

    for i in range(n):
        # a_txt = input()
        l_txt = abc_list[i][0]
        r_txt = abc_list[i][1]

        if dct[l_txt] < dct[r_txt]:
            abc(dct, r_txt, l_txt)
            ans_list.append(l_txt)

        elif dct[l_txt] > dct[r_txt]:
            abc(dct, l_txt, r_txt)
            ans_list.append(r_txt)

        else:
            if dct[l_txt] == dct[r_txt] == 0:
                print('No')
                break
            else:
                if l_txt in abc_list[i + 1]:
                    abc(dct, r_txt, l_txt)
                    ans_list.append(l_txt)
                elif r_txt in abc_list[i + 1]:
                    abc(dct, l_txt, r_txt)
                    ans_list.append(r_txt)
    else:
        print('Yes')
        print(*ans_list, sep='\n')


def __starting_point():
    main()

__starting_point()

N, A, B, C = map(int, input().split())
ss = [input() for _ in range(N)]

history = []

def move_to_flatten(s):
    nonlocal A, B, C, history
    if s == "AB":
        if A >= B:
            A -= 1
            B += 1
            history.append("B")
        else:
            B -= 1
            A += 1
            history.append("A")
    elif s == "BC":
        if B >= C:
            B -= 1
            C += 1
            history.append("C")
        else:
            C -= 1
            B += 1
            history.append("B")
    elif s == "AC":
        if A >= C:
            A -= 1
            C += 1
            history.append("C")
        else:
            C -= 1
            A += 1
            history.append("A")
        

for i, s in enumerate(ss):
    zeros = (A, B, C).count(0)
    if zeros == 0:
        move_to_flatten(s)
    elif zeros == 1:
        if A + B + C == 2:
            if A == 0:
                if s == "BC":
                    if i+1 < N and 'B' in ss[i+1]: 
                        C -= 1
                        B += 1
                        history.append('B')
                    else:
                        B -= 1
                        C += 1
                        history.append('C')
                else:
                    move_to_flatten(s)
            elif B == 0:
                if s == "AC":
                    if i+1 < N and 'C' in ss[i+1]:
                        A -= 1
                        C += 1
                        history.append('C')
                    else:
                        C -= 1
                        A += 1
                        history.append('A')
                else:
                    move_to_flatten(s)
            elif C == 0:
                if s == "AB":
                    if i+1 < N and 'A' in ss[i+1]:
                        B -= 1
                        A += 1
                        history.append('A')
                    else:
                        A -= 1
                        B += 1
                        history.append('B')
                else:
                    move_to_flatten(s)    
        else:
            move_to_flatten(s)
    elif zeros == 2:
        if A != 0 and s == "BC":
            print("No")
            return
        elif B != 0 and s == "AC":
            print("No")
            return
        elif C != 0 and s == "AB":
            print("No")
            return
        move_to_flatten(s)
    else:
        print("No")
        return

print("Yes")
print(*history, sep = '\n')

n,a,b,c = list(map(int, input().split()))
m = {'A':a, 'B':b, 'C':c}

ss = [input() for _ in range(n)]


ans = []
def _t(s0, s1):
    m[s0] = m[s0] + 1
    m[s1] = m[s1] - 1
    ans.append(s0)


if a+b+c == 0:
    print('No')
    return


elif a+b+c == 1:
    for k, v in list(m.items()):
        if v == 1:
            o = k

    for s in ss:
        if o not in s:
            print('No')
            return
        o = s.strip(o)
        ans.append(o)

elif a+b+c == 2:
    for i, s in enumerate(ss):
        if m[s[0]] + m[s[1]] == 0:
            print('No')
            return
        if m[s[0]] > m[s[1]]:
            _t(s[1], s[0])
        elif m[s[0]] < m[s[1]]:
            _t(s[0], s[1])
        else:
            if i < len(ss)-1 and s[0] in ss[i+1]:
                _t(s[0], s[1])
            else:
                _t(s[1], s[0])

else:
    for s in ss:
        if m[s[0]] + m[s[1]] == 0:
            print('No')
            return
        if m[s[0]] > m[s[1]]:
            _t(s[1], s[0])
        else:
            _t(s[0], s[1])

print('Yes')
for a in ans:
    print(a)


def operate(S,A,B,C,N):
    OP = []
    for i in range(N):
        if S[i] == "AB":
            if A == 0 and B == 0:
                return -1
            else:
                if A == 1 and B == 1 and i < N-1:
                    if S[i+1] == "BC":
                        OP.append("B")
                        A,B = A-1,B+1
                    else:
                        OP.append("A")
                        A,B = A+1,B-1
                elif A >= B:
                    OP.append("B")
                    A,B = A-1,B+1
                else:
                    OP.append("A")
                    A,B = A+1,B-1
        if S[i] == "BC":
            if B == 0 and C == 0:
                return -1
            else:
                if B == 1 and C == 1 and i < N-1:
                    if S[i+1] == "AB":
                        OP.append("B")
                        B,C = B+1,C-1
                    else:
                        OP.append("C")
                        B,C = B-1,C+1
                elif B >= C:
                    OP.append("C")
                    B,C = B-1,C+1
                else:
                    OP.append("B")
                    B,C = B+1,C-1
        if S[i] == "AC":
            if A == 0 and C == 0:
                return -1
            else:
                if A == 1 and C == 1 and i < N-1:
                    if S[i+1] == "BC":
                        OP.append("C")
                        A,C = A-1,C+1
                    else:
                        OP.append("A")
                        A,C = A+1,C-1
                elif C >= A:
                    OP.append("A")
                    C,A = C-1,A+1
                else:
                    OP.append("C")
                    C,A = C+1,A-1
    return OP

def main():
    N,A,B,C = list(map(int,input().split()))
    S = [input() for _ in range(N)]

    ans = operate(S,A,B,C,N)
    if ans != -1:
        print("Yes")
        for i in range(N):
            print((ans[i]))
    else:
        print("No")

def __starting_point():
    main()

__starting_point()

def select(x, y, ops, i, z):
    # true -> x を増やす
    if not(x == 1 and y == 1 and i < len(ops) - 1):
        if x < y:
            return True
        else:
            return False

    # x = y = 1, i < len(ops) - 1
    # 先読みして xz なら x を増やす
    # 先読みして xy なら y を増やす
    # 先読みして xy なら どっちでもいい
    op = ops[i]
    nop = ops[i+1]

    oo = (op, nop)
    if op == nop:
        return True

    if oo in [("AB", "AC"), ("BC", "AB"), ("AC", "AB")]:
        return True

    return False

def main():
    nabc = [int(_x) for _x in input().split()]
    n = nabc[0]
    a = nabc[1]
    b = nabc[2]
    c = nabc[3]

    ops = []
    for i in range(n):
        ops.append(input())

    result = []
    for i in range(n):
        op = ops[i]
        if op == "AB":
            if select(a, b, ops, i, c):
                result.append("A")
                a+=1
                b-=1
            else:
                result.append("B")
                a-=1
                b+=1
        if op == "AC":
            if select(a, c, ops, i, b):
                result.append("A")
                a+=1
                c-=1
            else:
                result.append("C")
                a-=1
                c+=1
        if op == "BC":
            if select(b, c, ops, i, a):
                result.append("B")
                b+=1
                c-=1
            else:
                result.append("C")
                b-=1
                c+=1                
        if a <0 or b<0 or c<0:
            print("No")
            return

    print("Yes")
    for r in result:
        print(r)

main()



n, a, b, c = list(map(int, input().split()))
s = [list(input()) for _ in range(n)]
s.append(["A", "B"])
d = {"A": a, "B": b, "C": c}
ans = []

def calc(add, sub):
    d[add] += 1
    d[sub] -= 1
    ans.append(add)

for i, [j, k] in enumerate(s):
    if i == n:
        print('Yes')
        print(('\n'.join(ans)))
        break
    if d[j] == 0 and d[k] == 0:
        print("No")
        break
    elif j == "A" and k == "B":
        
        if d[j] < d[k]:
            calc(j, k)
        elif d[j] > d[k]:
            calc(k, j)
        else:
            if s[i + 1][0] == "A":
                calc(j, k)
            else:
                calc(k, j)
    elif j == "A" and k == "C":

        if d[j] < d[k]:
            calc(j, k)
        elif d[j] > d[k]:
            calc(k, j)
        else:
            if s[i + 1][0] == "A":
                calc(j, k)
            else:
                calc(k, j)
    elif j == "B" and k == "C":

        if d[j] < d[k]:
            calc(j, k)
        elif d[j] > d[k]:
            calc(k, j)
        else:
            if s[i + 1][0] == "A" and s[i + 1][1] == "C":
                calc(k, j)
            else:
                calc(j, k)
    


import sys
readline = sys.stdin.readline

N,A,B,C = list(map(int,readline().split()))

val = [A,B,C]
# 0,0を作ってはいけない
# 基本的には小さいほうに1を足す
# 両方とも1の場合は、次の操作で選ばれるほうに1を足す
# 両方とも次の操作で選ばれるときはどちらに足してもよい

S = [readline().rstrip() for i in range(N)]
ans = []

def get_ind(s):
  res = []
  for c in s:
    if c == "A":
      res.append(0)
    elif c == "B":
      res.append(1)
    elif c == "C":
      res.append(2)
  return res

def get_alpha(x):
  return "ABC"[x]

for i in range(N):
  ind_x,ind_y = get_ind(S[i])
  if val[ind_x] == 0 and val[ind_y] == 0:
    print("No")
    return
  if val[ind_x] < val[ind_y]:
    ans += [get_alpha(ind_x)]
    val[ind_x] += 1
    val[ind_y] -= 1
  elif val[ind_x] > val[ind_y]:
    ans += [get_alpha(ind_y)]
    val[ind_y] += 1
    val[ind_x] -= 1
  else:
    if i + 1 < N and get_alpha(ind_x) in S[i + 1]:
      ans += [get_alpha(ind_x)]
      val[ind_x] += 1
      val[ind_y] -= 1
    else:
      ans += [get_alpha(ind_y)]
      val[ind_y] += 1
      val[ind_x] -= 1
      
print("Yes")
for a in ans:
  print(a)


def put(ret, val):
    if val == 0:
        ret.append('A')
    elif val == 1:
        ret.append('B')
    else:
        ret.append('C')


n, a, b, c = list(map(int, input().split()))

s = []

for i in range(n):
    tmp = input()
    if tmp == 'AB':
        val = 0
    elif tmp == 'BC':
        val = 1
    else:
        val = 2
    s.append(val)

ret = []
if a + b + c == 0:
    print('No')
    return
elif a + b + c == 1:
    t = []
    t.append(a)
    t.append(b)
    t.append(c)
    for i, item in enumerate(s):
        if t[item] == 1:
            t[item] = 0
            t[(item+1) % 3] = 1
            put(ret, (item+1) % 3)
        elif t[(item+1) % 3] == 1:
            t[item] = 1
            t[(item+1) % 3] = 0
            put(ret, item)
        else:
            print('No')
            return
elif a + b + c == 2:
    t = []
    t.append(a)
    t.append(b)
    t.append(c)
    for i, item in enumerate(s):
        if t[item] == 0 and t[(item+1) % 3] == 0:
            print('No')
            return
        if t[item] > t[(item+1) % 3]:
            t[item] -= 1
            t[(item+1) % 3] += 1
            put(ret, (item+1) % 3)
        elif t[item] < t[(item+1) % 3]:
            t[item] += 1
            t[(item+1) % 3] -= 1
            put(ret, item)
        elif t[item] == 0:
            print('No')
            return
        elif t[item] == 2:
            t[item] -= 1
            t[(item+1) % 3] += 1
            put(ret, (item+1) % 3)
        else:
            if len(s) > i + 1:
                if s[i+1] == (item + 1) % 3:
                    t[item] -= 1
                    t[(item+1) % 3] += 1
                    put(ret, (item+1) % 3)
                else:
                    t[item] += 1
                    t[(item+1) % 3] -= 1
                    put(ret, item)
            else:
                put(ret, item)

else:
    t = []
    t.append(a)
    t.append(b)
    t.append(c)
    for i, item in enumerate(s):
        if t[item] == 0 and t[(item+1) % 3] == 0:
            print('No')
            return
        if t[item] > t[(item+1) % 3]:
            t[item] -= 1
            t[(item+1) % 3] += 1
            put(ret, (item+1) % 3)
        else:
            t[item] += 1
            t[(item+1) % 3] -= 1
            put(ret, item)

print('Yes')
for item in ret:
    print(item)


n,a,b,c=map(int,input().split())
s=[input()for _ in range(n)]
if (a+b+c)==0:
  print("No")
if (a+b+c)==1 or (a+b+c)>=3:
  ans=[]
  for i in s:
    if i=="AB":
      if a<b:ans.append("A");a+=1;b+=-1;c+=0
      else:ans.append("B");a+=-1;b+=1;c+=0
    if i=="BC":
      if b<c:ans.append("B");a+=0;b+=1;c+=-1
      else:ans.append("C");a+=0;b+=-1;c+=1
    if i=="AC":
      if a<c:ans.append("A");a+=1;b+=0;c+=-1
      else:ans.append("C");a+=-1;b+=0;c+=1
    if min(a,b,c)<0:
      print("No");return
  print("Yes")
  for i in ans:print(i)
if (a+b+c)==2:
  ans=[]
  for i in range(n-1):
    if s[i]=="AB":
      if a==b:
        if s[i+1]=="AC":ans.append("A");a+=1;b+=-1;c+=0
        else:ans.append("B");a+=-1;b+=1;c+=0
      elif a<b:ans.append("A");a+=1;b+=-1;c+=0
      else:ans.append("B");a+=-1;b+=1;c+=0
    if s[i]=="BC":
      if b==c:
        if s[i+1]=="AC":ans.append("C");a+=0;b+=-1;c+=1
        else:ans.append("B");a+=0;b+=1;c+=-1
      elif b<c:ans.append("B");a+=0;b+=1;c+=-1
      else:ans.append("C");a+=0;b+=-1;c+=1
    if s[i]=="AC":
      if a==c:
        if s[i+1]=="BC":ans.append("C");a+=-1;b+=0;c+=1
        else:ans.append("A");a+=1;b+=0;c+=-1
      elif a<c:ans.append("A");a+=1;b+=0;c+=-1
      else:ans.append("C");a+=-1;b+=0;c+=1
    if min(a,b,c)<0:
      print("No");return
  for i in s[n-1:]:
    if i=="AB":
      if a<b:ans.append("A");a+=1;b+=-1;c+=0
      else:ans.append("B");a+=-1;b+=1;c+=0
    if i=="BC":
      if b<c:ans.append("B");a+=0;b+=1;c+=-1
      else:ans.append("C");a+=0;b+=-1;c+=1
    if i=="AC":
      if a<c:ans.append("A");a+=1;b+=0;c+=-1
      else:ans.append("C");a+=-1;b+=0;c+=1
    if min(a,b,c)<0:
      print("No");return
  print("Yes")
  for i in ans:print(i)

n,a,b,c=map(int,input().split())
s=list(input() for i in range(n))+["XX"]
ans=["Yes"]

if a+b+c==0:
  del ans[:]
  ans+=["No"]
  
if a+b+c==1:
  for j in range(n):
    
    if s[j]=="AB":
      if c==1:
        del ans[:]
        ans+=["No"]
        break        
      elif a==1:
        a-=1
        b+=1
        ans+=["B"]
      elif b==1:
        a+=1
        b-=1
        ans+=["A"]

    if s[j]=="AC":
      if b==1:
        del ans[:]
        ans+=["No"]
        break       
      elif a==1:
        a-=1
        c+=1
        ans+=["C"]
      elif c==1:
        a+=1
        c-=1
        ans+=["A"] 

    if s[j]=="BC":
      if a==1:
        del ans[:]
        ans+=["No"]
        break
      elif b==1:
        b-=1
        c+=1
        ans+="C"
      elif c==1:
        b+=1
        c-=1
        ans+=["B"]  

if a+b+c==2:
  for j in range(n):
    if s[j]=="AB":
      if a==2:
        a-=1
        b+=1
        ans+=["B"]
      elif b==2:
        a+=1
        b-=1
        ans+=["A"]
      elif c==2:
        del ans[:]
        ans+=["No"]
        break     
      elif (a==1 and b==1) and (s[j+1]=="AB" or s[j+1]=="AC" or s[j+1]=="XX"):
        a+=1
        b-=1
        ans+=["A"]
      elif (a==1 and b==1) and (s[j+1]=="BC"):
        a-=1
        b+=1
        ans+=["B"]
      elif a==1 and c==1:
        a-=1
        b+=1
        ans+=["B"]
      elif b==1 and c==1:
        a+=1
        b-=1
        ans+=["A"]
    
    if s[j]=="AC":
      if a==2:
        a-=1
        c+=1
        ans+=["C"]
      elif c==2:
        a+=1
        c-=1
        ans+=["A"] 
      elif b==2:
        del ans[:]
        ans+=["No"]
        break     
      elif (a==1 and c==1) and (s[j+1]=="AB" or s[j+1]=="AC" or s[j+1]=="XX"):
        a+=1
        c-=1
        ans+=["A"]
      elif (a==1 and c==1) and (s[j+1]=="BC"):
        a-=1
        c+=1
        ans+=["C"]
      elif a==1 and b==1:
        a-=1
        c+=1
        ans+=["C"]
      elif b==1 and c==1:
        a+=1
        c-=1
        ans+=["A"]

    if s[j]=="BC":
      if c==2:
        c-=1
        b+=1
        ans+=["B"]
      elif b==2:
        c+=1
        b-=1
        ans+=["C"] 
      elif a==2:
        del ans[:]
        ans+=["No"]
        break     
      elif (c==1 and b==1) and (s[j+1]=="AB" or s[j+1]=="BC" or s[j+1]=="XX"):
        b+=1
        c-=1
        ans+=["B"]
      elif (c==1 and b==1) and (s[j+1]=="AC"):
        b-=1
        c+=1
        ans+=["C"]
      elif a==1 and c==1:
        c-=1
        b+=1
        ans+=["B"]
      elif b==1 and a==1:
        c+=1
        b-=1
        ans+=["C"]        

if a+b+c>=3:
  if s[0]=="AB" and a+b==0 or s[0]=="AC" and a+c==0 or s[0]=="BC" and b+c==0:
    del ans[:]
    ans+=["No"]
  
  else:
    for j in range(n):
      if s[j]=="AB":
        if a>b:
          a-=1
          b+=1
          ans+=["B"]
        elif a<=b:
          a+=1
          b-=1
          ans+=["A"]
        
      if s[j]=="AC":
        if a>c:
          a-=1
          c+=1
          ans+=["C"]
        elif a<=c:
          a+=1
          c-=1
          ans+=["A"]     

      if s[j]=="BC":
        if b>c:
          b-=1
          c+=1
          ans+=["C"]
        elif b<=c:
          b+=1
          c-=1
          ans+=["B"]

for an in ans:
  print(an)

N,A,B,C=map(int,input().split())

if A+B+C==0:
  print("No")
elif A+B+C==1:
  ans_list=[]
  for _ in range(N):
    com=input()
    if com=="AB":
      if A==1:
        A-=1
        B+=1
        ans_list.append("B")
      elif B==1:
        A+=1
        B-=1
        ans_list.append("A")
      else:
        print("No")
        break
    elif com=="AC":
      if A==1:
        A-=1
        C+=1
        ans_list.append("C")
      elif C==1:
        A+=1
        C-=1
        ans_list.append("A")
      else:
        print("No")
        break
    elif com=="BC":
      if B==1:
        B-=1
        C+=1
        ans_list.append("C")
      elif C==1:
        B+=1
        C-=1
        ans_list.append("B")
      else:
        print("No")
        break
  else:
    print("Yes")
    for ans in ans_list:
      print(ans)
else:
  com_list=[]
  for i in range(N):
    com_list.append(input())
  
  for i in range(N):
    com=com_list[i]
    if com=="AB":
      if i==0 and A==0 and B==0:
        print("No")
        break
      elif i==0:
        print("Yes")
      
      if i<N-1 and A+B+C==2 and A==1 and B==1 and com!=com_list[i+1]:
        if com_list[i+1]=="AC":
          A+=1
          B-=1
          print("A")
        elif com_list[i+1]=="BC":
          A-=1
          B+=1
          print("B")
      else:
        if A>=B:
          A-=1
          B+=1
          print("B")
        else:
          A+=1
          B-=1
          print("A")
    elif com=="AC":
      if i==0 and A==0 and C==0:
        print("No")
        break
      elif i==0:
        print("Yes")
      
      if i<N-1 and A+B+C==2 and A==1 and C==1 and com!=com_list[i+1]:
        if com_list[i+1]=="AB":
          A+=1
          C-=1
          print("A")
        elif com_list[i+1]=="BC":
          A-=1
          C+=1
          print("C")
      else:
        if A>=C:
          A-=1
          C+=1
          print("C")
        else:
          A+=1
          C-=1
          print("A")
    elif com=="BC":
      if i==0 and B==0 and C==0:
        print("No")
        break
      elif i==0:
        print("Yes")
      
      if i<N-1 and A+B+C==2 and B==1 and C==1 and com!=com_list[i+1]:
        if com_list[i+1]=="AB":
          B+=1
          C-=1
          print("B")
        elif com_list[i+1]=="AC":
          B-=1
          C+=1
          print("C")
      else:
        if B>=C:
          B-=1
          C+=1
          print("C")
        else:
          B+=1
          C-=1
          print("B")

N, *v = map(int, input().split())
S = [input() for _ in range(N)]
Z = []
for i, s, t in zip(range(N), S, S[1:]+["ZZ"]):
    a, b, c = v
    if s == "AB":
        if a == b == 0:
            print("No");return
        elif a < b:
            v[0] += 1
            v[1] -= 1
            Z.append("A")
        elif a > b:
            v[0] -= 1
            v[1] += 1
            Z.append("B") 
        elif t == "AC":
            v[0] += 1
            v[1] -= 1
            Z.append("A")
        else:
            v[0] -= 1
            v[1] += 1
            Z.append("B")
    elif s == "AC":
        if a == c == 0:
            print("No");return
        elif a < c:
            v[0] += 1
            v[2] -= 1
            Z.append("A")
        elif a > c:
            v[0] -= 1
            v[2] += 1
            Z.append("C") 
        elif t == "AB":
            v[0] += 1
            v[2] -= 1
            Z.append("A")
        else:
            v[0] -= 1
            v[2] += 1
            Z.append("C")
    else:
        if b == c == 0:
            print("No");return
        elif b < c:
            v[1] += 1
            v[2] -= 1
            Z.append("B")
        elif b > c:
            v[1] -= 1
            v[2] += 1
            Z.append("C") 
        elif t == "AB":
            v[1] += 1
            v[2] -= 1
            Z.append("B")
        else:
            v[1] -= 1
            v[2] += 1
            Z.append("C")

print("Yes")
for z in Z: print(z)

import sys
readline = sys.stdin.readline


def solve(writer):
    N, A, B, C = list(map(int, input().split()))

    variables = {
        'A': A,
        'B': B,
        'C': C
    }

    queries = (list(readline().strip()) for _ in range(N))

    next_q = next(queries)

    for i in range(N):

        let_1, let_2 = next_q
        next_q = next(queries) if i != N - 1 else ()

        if variables[let_1] == variables[let_2] == 0:
            return False

        if variables[let_1] == variables[let_2] == 1 and let_2 in next_q \
                or variables[let_1] > variables[let_2]:
            let_1, let_2 = let_2, let_1

        variables[let_1] += 1
        variables[let_2] -= 1

        writer.append(let_1)

    return True


def main():
    writer = ['Yes']
    ok = solve(writer)
    if ok:
        for w in writer:
            print(w)
    else:
        print('No')


def __starting_point():
    main()

__starting_point()

import sys

sys.setrecursionlimit(10 ** 7)

# ----------

INF = float("inf")
MOD = 10 ** 9 + 7

N, A, B, C = list(map(int, input().split()))
num = [A, B, C]
S = []
for i in range(N):
    S.append(input().strip())
S.append('AB')

ans = []
for i in range(N):
    s = S[i]
    s1 = s[0]
    s2 = s[1]
    n1 = num["ABC".index(s1)]
    n2 = num["ABC".index(s2)]
    if n1 == n2 == 0:
        print("No")
        return
    if n1 == 0:
        num["ABC".index(s1)] += 1
        num["ABC".index(s2)] -= 1
        ans.append(s1)
        continue
    if n2 == 0:
        num["ABC".index(s1)] -= 1
        num["ABC".index(s2)] += 1
        ans.append(s2)
        continue
    if s1 in S[i + 1]:
        num["ABC".index(s1)] += 1
        num["ABC".index(s2)] -= 1
        ans.append(s1)
    else:
        num["ABC".index(s1)] -= 1
        num["ABC".index(s2)] += 1
        ans.append(s2)

print('Yes')
for a in ans:
    print(a)


def main():
    N, A, B, C = list(map(int, input().split()))
    S = [{'AB':(0, 1), 'BC': (1, 2), 'AC': (0, 2)}[input()] for _ in range(N)]
    ABC = [A, B, C]
    RR = ['A', 'B', 'C']
    R = []
    for i, (s1, s2) in enumerate(S):
        if ABC[s1] == 0 and ABC[s2] == 0:
            return False, None
        if ABC[s1] < ABC[s2]:
            s1, s2 = s2, s1
        if A + B + C == 2 and ABC[s1] == 1 and ABC[s2] == 1 and i < N - 1 and S[i] != S[i + 1]:
            s1n, s2n = S[i + 1]
            if s1 in [s1n, s2n]:
                s1, s2 = s2, s1
        ABC[s1] -= 1
        ABC[s2] += 1
        R.append(RR[s2])
    return True, R

a, s = main()
if not a:
    print('No')
else:
    print('Yes')
    print(('\n'.join(s)))


N,A,B,C=list(map(int,input().split()))

S=['']*N
for i in range(N):
    S[i]=input()

result=[]
kekka=True


for i in range(N):
    if (A==0 and B==0 and S[i]=='AB') or (C==0 and B==0 and S[i]=='BC') or (A==0 and C==0 and S[i]=='AC'):
        kekka=False
        break
    else:
        if S[i]=='AB':
            if A==0:
                A += 1
                B -= 1
                result.append('A')
            elif B==0:
                A -=1
                B +=1
                result.append('B')
            elif A==1 and B==1 and C==0 and i !=N-1:
                if S[i+1]=='AC':
                    A += 1
                    B -= 1
                    result.append('A')
                else:
                    A -=1
                    B +=1
                    result.append('B')
            elif A>B:
                A -=1
                B +=1
                result.append('B')
            else:
                A +=1
                B -=1
                result.append('A')
        elif S[i]=='AC':
            if A==0:
                A += 1
                C -= 1
                result.append('A')
            elif C==0:
                A -=1
                C +=1
                result.append('C')
            elif A==1 and C==1 and B==0 and i != N-1:
                if S[i+1]=='AB':
                    A += 1
                    C -= 1
                    result.append('A')
                else:
                    A -=1
                    C +=1
                    result.append('C')
            elif A>C:
                A -=1
                C +=1
                result.append('C')
            else:
                A +=1
                C -=1
                result.append('A') 
        else:
            if B==0:
                B += 1
                C -= 1
                result.append('B')
            elif C==0:
                B -=1
                C +=1
                result.append('C')
            elif B==1 and C==1 and A==0 and i != N-1:
                if S[i+1]=='AB':
                    B += 1
                    C -= 1
                    result.append('B')
                else:
                    B -=1
                    C +=1
                    result.append('C')
            elif B>C:
                B -=1
                C +=1
                result.append('C')
            else:
                B +=1
                C -=1
                result.append('B')

if kekka ==False:
    print('No')
else:
    print('Yes')
    for i in range(N):
        print((result[i]))            




n,A,B,C=map(int,input().split())
r=[A,B,C]
g=list()
for i in range(n):
    g.append(str(input()))
    
def re(string):
    if string=="AB":
        return(0,1)
    elif string=="AC":
        return(0,2)
    else:
        return(1,2)
    
def al(num):
    if num==0:
        return "A"
    elif num==1:
        return "B"
    else:
        return "C"
    
flag=0
result=list()
for i in range(n):
    a,b=re(g[i])
    if r[a]==0 and r[b]==0:
        print("No")
        flag=1
        break
    elif r[a]>r[b]:
        r[a]-=1
        r[b]+=1
        result.append(al(b))
    elif r[a]<r[b]:
        r[a]+=1
        r[b]-=1
        result.append(al(a))
    else:
        if i+1==n:
            r[a]+=1
            r[b]-=1
            result.append(al(a))
            break
        x,y=re(g[i+1])
        if (x,y)==(a,b):
            r[a]+=1
            r[b]-=1
            result.append(al(a))
        else:
            if x in (a,b):
                r[x]+=2
                r[a]-=1;r[b]-=1
                result.append(al(x))
            else:
                r[y]+=2
                r[a]-=1;r[b]-=1
                result.append(al(y))
        
if flag==0:
    print("Yes")
    for item in result:
        print(item)

3
# -*- coding: utf-8 -*-
def check(s):
    if dict_x[s[0]] == 0 and dict_x[s[1]] == 0:
        return "NOT"
    elif  dict_x[s[0]] > 0 and dict_x[s[1]] == 0:
        return s[1]
    elif  dict_x[s[0]] == 0 and dict_x[s[1]] > 0:
        return s[0]
    elif dict_x[s[0]] == 1 and dict_x[s[1]] == 1:
        return "EVEN"
    else:
        if dict_x[s[0]] > dict_x[s[1]]:
            return s[1]
        else:
            return s[0] 
def update(s, mozi):
    if s[1] == mozi:
        dict_x[s[0]] -= 1
        dict_x[s[1]] += 1
    else:
        dict_x[s[0]] += 1
        dict_x[s[1]] -= 1

n, a, b, c = map(int, input().split())
dict_x = {"A": a, "B": b, "C": c}
s_list = []
ans_list = []
flag = 1
for i in range(0, n):
    s = input()
    s_list.append(s)
if a + b + c == 0:
    flag = 0
elif a + b + c == 1:
    for s in s_list:
        x = check(s)
        if x == "NOT":
            flag = 0
            break
        else:
            ans_list.append(x)
            update(s, x)
elif a + b + c == 2:
    i = 0
    for s in s_list:
        x = check(s)
        if x == "NOT":
            flag = 0
            break
        elif x == "EVEN":
            if i == len(s_list) - 1:
                ans_list.append(s[0])
                update(s, x)
            elif s == s_list[i + 1]:
                ans_list.append(s[0])
                update(s, x)
            else:
                if s[0] in s_list[i + 1]:
                    ans_list.append(s[0])
                    update(s, s[0])
                else:
                    ans_list.append(s[1])
                    update(s, s[1])
        else:
            ans_list.append(x)
            update(s, x)
        i += 1
else:
    for s in s_list:
        x = check(s)
        if x == "NOT":
            flag = 0
            break
        elif x == "EVEN":
            ans_list.append(s[0])
            update(s, s[0])
        else:
            ans_list.append(x)
            update(s, x)

if flag == 1:
    print("Yes")
    for ans in ans_list:
        print(ans)
else:
    print("No")

import sys
readline = sys.stdin.readline


def solve(writer):
    N, A, B, C = list(map(int, input().split()))

    variables = {
        'A': A,
        'B': B,
        'C': C
    }

    queries = (list(readline().strip()) for _ in range(N))

    next_q = next(queries)

    for i in range(N):

        let_1, let_2 = next_q
        next_q = next(queries) if i < N - 1 else ()

        if variables[let_1] == variables[let_2] == 0:
            return False

        if variables[let_1] == variables[let_2] == 1 and let_2 in next_q \
                or variables[let_1] > variables[let_2]:
            let_1, let_2 = let_2, let_1

        variables[let_1] += 1
        variables[let_2] -= 1

        writer.append(let_1)

    return True


def main():
    
    writer = list()
    ok = solve(writer)
    
    if ok:
        print('Yes')
        for w in writer:
            print(w)
    else:
        print('No')


def __starting_point():
    main()

__starting_point()

import sys


def xxx(val, op):
    target = []
    for i, o in enumerate(op):
        if sum([val[k] for k in o]) == 0:
            return []
        k0 = o[0]
        k1 = o[1]
        if val[k0] == 0:
            p, m = k0, k1
        elif val[k1] == 0:
            p, m = k1, k0
        elif i < len(op) - 1 and k1 in op[i+1]:
            p, m = k1, k0
        else:
            p, m = k0, k1
        val[p] += 1
        val[m] -= 1
        target.append(p)
    return target


n, a, b, c = [int(x) for x in input().split()]
op = [sys.stdin.readline().strip() for _ in range(n)]
val = {"A": a, "B": b, "C": c}

target = xxx(val, op)
if len(target) == 0:
    print("No")
else:
    print("Yes")
    for t in target:
        print(t)


N, A, B, C = map(int, input().split())
dt = {'AB': (0, 1), 'AC': (0, 2), 'BC': (1, 2)}
Q = [dt[input()] for _ in range(N)]


class Game:
    def __init__(self, ABC):
        self.ABC = ABC
        self.ds = {0: 'A', 1: 'B', 2: 'C'}
        self.ans = []

    def add_q0(self, q0, q1):
        self.ans.append(self.ds[q0])
        self.ABC[q0] += 1
        self.ABC[q1] -= 1

    def add_q1(self, q0, q1):
        self.ans.append(self.ds[q1])
        self.ABC[q0] -= 1
        self.ABC[q1] += 1


def solve1(ABC):
    G = Game(ABC)
    for q0, q1 in Q:
        if G.ABC[q0] == G.ABC[q1] == 0:
            print('No')
            return
        elif G.ABC[q0] == 0:
            G.add_q0(q0, q1)
        else:
            G.add_q1(q0, q1)
    print('Yes')
    print(*G.ans, sep='\n')


def solve2(ABC):
    G = Game(ABC)
    for i, (q0, q1) in enumerate(Q):
        if G.ABC[q0] == G.ABC[q1] == 0:
            print('No')
            return
        elif G.ABC[q0] == 0:
            G.add_q0(q0, q1)
        elif G.ABC[q1] == 0:
            G.add_q1(q0, q1)
        elif G.ABC[q0] == G.ABC[q1] == 1 and i < N - 1:
            if q0 in Q[i + 1]:
                G.add_q0(q0, q1)
            else:
                G.add_q1(q0, q1)
        else:
            # 余裕の無い方に足しておく
            if G.ABC[q0] <= G.ABC[q1]:
                G.add_q0(q0, q1)
            else:
                G.add_q1(q0, q1)
    print('Yes')
    print(*G.ans, sep='\n')


def solve3(ABC):
    G = Game(ABC)
    for q0, q1 in Q:
        if G.ABC[q0] == G.ABC[q1] == 0:
            print('No')
            return
        elif G.ABC[q0] == 0:
            G.add_q0(q0, q1)
        elif G.ABC[q1] == 0:
            G.add_q1(q0, q1)
        else:
            # 余裕の無い方に足しておく
            if G.ABC[q0] <= G.ABC[q1]:
                G.add_q0(q0, q1)
            else:
                G.add_q1(q0, q1)
    print('Yes')
    print(*G.ans, sep='\n')


S = A + B + C
if S == 0:
    print('No')
elif S == 1:
    solve1([A, B, C])
elif S == 2:
    solve2([A, B, C])
else:
    solve3([A, B, C])


import sys

def str_to_int(ch):
	if ch =='A':
		return 0
	if ch =='B':
		return 1
	if ch =='C':
		return 2
def int_to_str(ch):
	if ch ==0:
		return 'A'
	if ch ==1:
		return 'B'
	if ch ==2:
		return 'C'

N, A, B, C = list(map(int, input().split()))
ABC =[0, 0, 0]
ABC[0] = A
ABC[1] = B
ABC[2] = C

ops = []
for _ in range(N):
	l =list(map(str_to_int, list(input())))
	ops.append(l)

if sum(ABC) == 0:
	print("No")
	return

ans = []
for idx, op in enumerate(ops):
	n0 = ABC[op[0]]
	n1 = ABC[op[1]]
	if n0 == 0 and n1 == 0:
		print("No")
		return
	elif n1 == 0:
		inc = op[1]
		dec = op[0]
	elif n0 == 0:
		inc = op[0]
		dec = op[1]
	elif idx +1 < len(ops) and op[0] in ops[idx+1]:
		inc = op[0]
		dec = op[1]
	else:
		inc = op[1]
		dec = op[0]
	ans.append(inc)
	ABC[dec]-=1
	ABC[inc]+=1
print("Yes")
for i in map(int_to_str, ans):
	print(i)
return



N,*X=map(int,input().split())
S=[input() for i in range(N)]
f=1
d={'AB':(0,1),'AC':(0,2),'BC':(1,2)}
x='ABC'
a=[]
for i in range(N):
    if X[d[S[i]][0]]==1 and X[d[S[i]][1]]==1 and X.count(0)==1 and i<N-1:
        if S[i][0] in S[i+1]:
            X[d[S[i]][0]]+=1
            X[d[S[i]][1]]-=1
            a.append(x[d[S[i]][0]])
        else:
            X[d[S[i]][0]]-=1
            X[d[S[i]][1]]+=1
            a.append(x[d[S[i]][1]])
    elif X[d[S[i]][0]]<X[d[S[i]][1]]:
        X[d[S[i]][0]]+=1
        X[d[S[i]][1]]-=1
        a.append(x[d[S[i]][0]])
    else:
        X[d[S[i]][0]]-=1
        X[d[S[i]][1]]+=1
        a.append(x[d[S[i]][1]])
    if -1 in X:
        f=0;break
print(['No','Yes'][f])
if f:print(*a,sep='\n')

N, A, B, C = list(map(int, input().split()))
d = {}
d["A"] = A
d["B"] = B
d["C"] = C
l = [input() for _ in range(N)]
v = A+B+C

def solve():
    res = []
    if v==0:
        return []
    elif v==1:
        for i in l:
            a, b = i
            if d[a]==0 and d[b]==0:
                return []
            elif d[a]>d[b]:
                d[a] -= 1
                d[b] += 1
                res.append(b)
            else:
                d[a] += 1
                d[b] -= 1
                res.append(a)
    else:
        a, b = l[0]
        if d[a]==0 and d[b]==0:
            return []
        else:
            for i, j in enumerate(l):
                a, b = j
                if d[a]>d[b]:
                    d[a] -= 1
                    d[b] += 1
                    res.append(b)
                elif d[a]==d[b]==1 and i+1<N:
                    e = set(l[i+1])&set([a, b])
                    if len(e)==1:
                        f = e.pop()
                        g = b if f==a else a
                        d[f] += 1
                        d[g] -= 1
                        res.append(f)
                    else:
                        d[a] -= 1
                        d[b] += 1
                        res.append(b)
                else:
                    d[a] += 1
                    d[b] -= 1
                    res.append(a)
    return res


r = solve()
if r:
    print("Yes")
    for i in r:
        print(i)
else:
    print("No")


# input
N, A, B, C = map(int, input().split())
S = [input() for _ in range(N)]

# process
V = {"A":A, "B":B, "C":C}
S.append("XX")
op = ""
for i in range(N):
    s0, s1 = S[i]
    if V[s0] + V[s1] == 0:
        break
    
    x, y = s0, s1
    if V[s1] == 0 or (V[s0] != 0 and s1 in S[i+1]):
        x, y = s1, s0

    V[x] += 1
    V[y] -= 1
    op += x

# output
if len(op) != N:
    print("No")
else:
    print("Yes")
    [print(x) for x in op]


def check(x,y,z,i,ops):
    if x == 1 and y == 1 and z == 0 and i < len(ops) - 1:        
        return (ops[i], ops[i+1]) in [("AB", "AC"), ("BC", "AB"), ("AC", "AB")]
    return (x <= y)

A=0
B=1
C=2
nabc = [int(_x) for _x in input().split()]
n = nabc[0]
abc = nabc[1:]
ops = []
for i in range(n):
    ops.append(input())

result = []
for i in range(n):
    op = ops[i]
    if op == "AB":
        (s,t,u) = (A,B,C)
    elif op == "BC":
        (s,t,u) = (B,C,A)
    else:
        (s,t,u) = (A,C,B)
    if check(abc[s],abc[t],abc[u],i,ops):
        result.append(s)
        abc[s] += 1
        abc[t] -= 1
    else:
        result.append(t)
        abc[s] -= 1
        abc[t] += 1
    if abc[s]<0 or abc[t]<0:
        print("No")
        break
else:
    print("Yes")
    for r in result:
        if r==A: print("A")
        if r==B: print("B")
        if r==C: print("C")


n,a,b,c=map(int,input().split())
arr=[input() for _ in range(n)]
ans=[]
for i in range(n):
  if arr[i]=='AB':
    if a==1 and b==1:
      if i==n-1 or arr[i+1]=='AB' or arr[i+1]=='AC':
        a+=1
        b-=1
        ans.append('A')
      elif arr[i+1]=='BC':
        a-=1
        b+=1
        ans.append('B')
    elif a==0 and b==0:
      print('No')
      break
    else:
      if a>=b:
        a-=1
        b+=1
        ans.append('B')
      else:
        a+=1
        b-=1
        ans.append('A')
  elif arr[i]=='AC':
    if a==1 and c==1:
      if i==n-1 or arr[i+1]=='AC' or arr[i+1]=='AB':
        a+=1
        c-=1
        ans.append('A')
      elif arr[i+1]=='BC':
        a-=1
        c+=1
        ans.append('C')
    elif a==0 and c==0:
      print('No')
      break
    else:
      if a>=c:
        a-=1
        c+=1
        ans.append('C')
      else:
        a+=1
        c-=1
        ans.append('A')
  elif arr[i]=='BC':
    if b==1 and c==1:
      if i==n-1 or arr[i+1]=='BC' or arr[i+1]=='AB':
        b+=1
        c-=1
        ans.append('B')
      elif arr[i+1]=='AC':
        b-=1
        c+=1
        ans.append('C')
    elif b==0 and c==0:
      print('No')
      break
    else:
      if b>=c:
        b-=1
        c+=1
        ans.append('C')
      else:
        b+=1
        c-=1
        ans.append('B')
else:
  print('Yes')
  for i in range(n):
    print(ans[i])

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,a,b,c = LI()
    t = [a,b,c]
    q = [S() for _ in range(n)] + ["ABC"]
    r = []
    for qi in range(n):
        s = q[qi]
        if s == "AB":
            i = 0
            j = 1
        elif s == "AC":
            i = 0
            j = 2
        else:
            i = 1
            j = 2

        if t[i] < t[j]:
            r.append(i)
            t[i] += 1
            t[j] -= 1
        elif t[i] > t[j]:
            r.append(j)
            t[i] -= 1
            t[j] += 1
        else:
            if t[i] < 1:
                return "No"
            if chr(ord("A") + i) in q[qi+1]:
                r.append(i)
                t[i] += 1
                t[j] -= 1
            else:
                r.append(j)
                t[i] -= 1
                t[j] += 1

    return JA(["Yes"] + list(map(lambda x: chr(ord("A") + x), r)), "\n")

print(main())





n,a,b,c = map(int, input().split())
s = [input() for _ in range(n)]

d = {'A':a,'B':b,'C':c}

ans = ['Yes']

for i in range(n):
    if d[s[i][0]] == 0 and d[s[i][1]] == 0:
        print('No')
        return
    if d[s[i][0]] == 1 and d[s[i][1]] == 1 and n-i > 1:
        d[s[i][0]] = 2
        d[s[i][1]] = 0
        if d[s[i+1][0]] == 0 and d[s[i+1][1]] ==0:
            d[s[i][0]] = 0
            d[s[i][1]] = 2
            ans.append(s[i][1])
        else:
            ans.append(s[i][0])
    elif d[s[i][0]] >= d[s[i][1]]:
        d[s[i][0]] = d[s[i][0]] - 1
        d[s[i][1]] = d[s[i][1]] + 1
        ans.append(s[i][1])
    else:
        d[s[i][0]] = d[s[i][0]] + 1
        d[s[i][1]] = d[s[i][1]] - 1
        ans.append(s[i][0])

for i in range(n+1):
    print(ans[i])

N, A, B, C = list(map(int, input().split()))
S = [input() for _ in range(N)]

A, B, C = min(A, 2), min(B, 2), min(C, 2)
X = [0, A, B, C]  # 1-indexecの方が楽そう
F = {1: 'A', 2: 'B', 3: 'C'}

ans = []
for k, s in enumerate(S):
    if s == 'AB':
        i, j = 1, 2
    elif s == 'BC':
        i, j = 2, 3
    elif s == 'AC':
        i, j = 1, 3

    if X[i] > X[j]:
        X[i] -= 1
        X[j] += 1
        ans.append(j)

    elif X[i] < X[j]:
        X[i] += 1
        X[j] -= 1
        ans.append(i)

    else:
        if (X[i] == X[j] == 1) and (k < N - 1):
            if ((S[k + 1][0] == F[i]) and (S[k + 1][1] == F[i ^ j])) or ((S[k + 1][0] == F[i ^ j]) and (S[k + 1][1] == F[i])):
                X[i] += 1
                X[j] -= 1
                ans.append(i)
            else:
                X[j] += 1
                X[i] -= 1
                ans.append(j)
        else:
            X[i] -= 1
            X[j] += 1
            ans.append(j)

    if any([x < 0 for x in X]):
        print('No')
        return

print('Yes')
for a in ans:
    print((F[a]))


n,a,b,c=map(int,input().split())
s=[0]*(n+1)
for i in range(n):
    s[i]=input()
l=[0]*(n+1)
for i in range(n):
    if s[i]=="AB":
        if a==b==0:
            print("No")
            return
        if a+b+c==2:
            if a==b==1:
                if s[i+1]=="AC":
                    a+=1
                    b-=1
                    l[i]="A"
                    continue
                elif s[i+1]=="BC":
                    a-=1
                    b+=1
                    l[i]="B"
                    continue
        if a>=b:
            a-=1
            b+=1
            l[i]="B"
        else:
            a+=1
            b-=1
            l[i]="A"
    if s[i]=="BC":
        if c==b==0:
            print("No")
            return
        if a+b+c==2:
            if b==c==1:
                if s[i+1]=="AB":
                    c-=1
                    b+=1
                    l[i]="B"
                    continue
                elif s[i+1]=="AC":
                    b-=1
                    c+=1
                    l[i]="C"
                    continue
        if b>=c:
            b-=1
            c+=1
            l[i]="C"
        else:
            b+=1
            c-=1
            l[i]="B"
    if s[i]=="AC":
        if a==c==0:
            print("No")
            return
        if a+b+c==2:
            if a==c==1:
                if s[i+1]=="AB":
                    c-=1
                    a+=1
                    l[i]="A"
                    continue
                elif s[i+1]=="BC":
                    a-=1
                    c+=1
                    l[i]="C"
                    continue
        if a>=c:
            a-=1
            c+=1
            l[i]="C"
        else:
            a+=1
            c-=1
            l[i]="A"
if l[-2]!=0:
    print("Yes")
    for i in range(n):
        print(l[i])

def main():
    N, A, B, C = list(map(int, input().split()))
    d = {'A':A, 'B':B, 'C':C}
    l = []
    for _ in range(N):
        s = input()
        l.append(s)
    r = []
    for i in range(N):
        x, y  = l[i][0], l[i][1]
        z = 'A'
        for j in d:
            if j not in l[i]:
                z = j
        if d[x] > d[y]:
            d[x] -= 1
            d[y] += 1
            r.append(y)
        elif d[y] > d[x]:
            d[x] += 1
            d[y] -= 1
            r.append(x)
        else:
            if d[x] > 1 or i == N-1:
                d[x] += 1
                d[y] -= 1
                r.append(x)
            elif set(l[i]) == set(l[i+1]):
                d[x] += 1
                d[y] -= 1
                r.append(x)
            else:
                x2 = 'A'
                for j in l[i+1]:
                    if j != z:
                        if j == y:
                            x, y = y, x
                if d[z] > 1:
                    d[x] -= 1
                    d[y] += 1
                    r.append(y)
                else:
                    d[x] += 1
                    d[y] -= 1
                    r.append(x)
            if d[x] < 0 or d[y] < 0 or d[z] < 0:
                return False, r
    return True, r
x, y = main()
if x:
    print('Yes')
    for i in y:
        print(i)
else:
    print('No')


import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
N, A, B, C = map(int, input().split())
S = [input().strip("\n").replace("A", "0").replace("B", "1").replace("C", "2") for _ in range(N)]
Ans = [None] * N

def search(i, num):
    if i == N:
        if min(num) >= 0: return True
        else: return False
    if min(num) < 0: return False
    L = [num[0], num[1], num[2]]
    f = S[i][0]
    s = S[i][1]
    L[int(f)] += 1
    L[int(s)] -= 1
    if search(i+1, L):
        Ans[i] = f
        return True
    L[int(f)] -= 2
    L[int(s)] += 2
    if search(i+1, L):
        Ans[i] = s
        return True
    return False

def solve():
    if search(0, [A, B, C]):
        print("Yes")
        for i, a in enumerate(Ans):
            if a == "0": print("A")
            elif a == "1": print("B")
            else: print("C")
    else: print("No")
    #print(Ans)

    return 0

def __starting_point():
    solve()
__starting_point()

import sys
n,a,b,c = list(map(int, input().split()))

s = list()
for i in range(n):
    s.append(input())

r = list()

for i in range(n):
    if s[i]=='AB':
        if a>b:
            r.append('B')
            a=a-1
            b=b+1
        elif a<b:
            r.append('A')
            a=a+1
            b=b-1
        else:
            if i==n-1 or 'A' in s[i+1]:
                r.append('A')
                a=a+1
                b=b-1
            else: 
                r.append('B')
                a=a-1
                b=b+1
    elif s[i]=='AC':
        if a>c:
            r.append('C')
            a=a-1
            c=c+1
        elif a<c:
            r.append('A')
            a=a+1
            c=c-1
        else:
            if i==n-1 or 'A' in s[i+1]:
                r.append('A')
                a=a+1
                c=c-1
            else: 
                r.append('C')
                a=a-1
                c=c+1
    else:
        if b>c:
            r.append('C')
            b=b-1
            c=c+1
        elif b<c:
            r.append('B')
            b=b+1
            c=c-1
        else:
            if i==n-1 or 'B' in s[i+1]:
                r.append('B')
                b=b+1
                c=c-1
            else: 
                r.append('C')
                b=b-1
                c=c+1
    if min(a,b,c)<0:
        print('No')
        return


print('Yes')
for str in r:
    print(str)


# greedyな選択：数字が小さいほうを増やし大きいほうを減らす。等しい場合どっちでもいい（とりあえず左を増やす）。
# 
# 初手 1 1 1 なら絶対成功 (greedy)
# どこかの状態で 1 1 1 を作れるなら絶対成功 (greedy)
# 0 1 2 なら絶対成功 (greedy)
# 0 0 3 で、初手がAB以外なら絶対成功 (greedy)
# 0 0 0 なら絶対失敗
#
# 初手で成否が分からないのは
# 0 1 1
# 0 0 2
# 0 0 1
#
# 0 0 1 は greedyにやるしかない
# 0 0 2 は、少なくとも1回はgreedy
#
# 結局、各回のgreedyでは問題になるのは
# 0 1 1 で 1 1 のペアでどっちを増やすか選ぶときのみ
# これは1個先を読めば十分


def select(x, y, ops, i, z):
    # true -> x を増やす
    if not(x == 1 and y == 1 and z == 0 and i < len(ops) - 1):
        if x <= y:
            return True
        else:
            return False

    # x = y = 1, z = 0, i < len(ops) - 1
    # 先読みして xz なら x を増やす
    # 先読みして xy なら y を増やす
    # 先読みして xy なら どっちでもいい
    op = ops[i]
    nop = ops[i+1]

    oo = (op, nop)
    if oo in [("AB", "AC"), ("BC", "AB"), ("AC", "AB")]:
        return True

    return False

def main():
    nabc = [int(_x) for _x in input().split()]
    n = nabc[0]
    a = nabc[1]
    b = nabc[2]
    c = nabc[3]

    ops = []
    for i in range(n):
        ops.append(input())

    result = []
    for i in range(n):
        op = ops[i]
        if op == "AB":
            if select(a, b, ops, i, c):
                result.append("A")
                a+=1
                b-=1
            else:
                result.append("B")
                a-=1
                b+=1
        if op == "AC":
            if select(a, c, ops, i, b):
                result.append("A")
                a+=1
                c-=1
            else:
                result.append("C")
                a-=1
                c+=1
        if op == "BC":
            if select(b, c, ops, i, a):
                result.append("B")
                b+=1
                c-=1
            else:
                result.append("C")
                b-=1
                c+=1
        if a <0 or b<0 or c<0:
            print("No")
            return

    print("Yes")
    for r in result:
        print(r)

main()


import sys
n, a, b, c = map(int, input().split())

if a+b+c == 0:
  print("No")
  return
elif a+b+c == 1:
  ans = [None]*n
  for i in range(n):
    s = input()
    if (s == "AB" and c == 1) or (s == "AC" and b == 1) or (s == "BC" and a == 1):
      print("No")
      return
    if s == "AB":
      if a == 1:
        ans[i] = "B"
        a, b = 0, 1
      else:
        ans[i] = "A"
        a, b = 1, 0
    if s == "BC":
      if b == 1:
        ans[i] = "C"
        b, c = 0, 1
      else:
        ans[i] = "B"
        b, c = 1, 0
    if s == "AC":
      if c == 1:
        ans[i] = "A"
        c, a = 0, 1
      else:
        ans[i] = "C"
        c, a = 1, 0
  print("Yes")
  for i in range(n):
    print(ans[i])

else:
  ans = [None]*n
  s = [input() for _ in range(n)]
  for i in range(n):
    if (s[i] == "AB" and a == 0 and b == 0) or (s[i] == "AC" and c == 0 and a == 0) or (s[i] == "BC" and b == c == 0):
      print("No")
      return
    if s[i] == "AB":
      if a == 0:
        ans[i] = "A"
        a += 1
        b -= 1
      elif b == 0:
        ans[i] = "B"
        a -= 1
        b += 1
      elif i != n-1 and s[i] != s[i+1]:
        if s[i+1] == "BC":
          ans[i] = "B"
          b += 1
          a -= 1
        if s[i+1] == "AC":
          ans[i] = "A"
          b -= 1
          a += 1
      else:
        if b > a:
          ans[i] = "A"
          a += 1
          b -= 1
        else:
          ans[i] = "B"
          a -= 1
          b += 1
          
      
    if s[i] == "BC":
      if b == 0:
        ans[i] = "B"
        b += 1
        c -= 1
      elif c == 0:
        ans[i] = "C"
        b -= 1
        c += 1
      elif i != n-1 and s[i] != s[i+1]:
        if s[i+1] == "AC":
          ans[i] = "C"
          c += 1
          b -= 1
        if s[i+1] == "AB":
          ans[i] = "B"
          c -= 1
          b += 1
      else:
        if b < c:
          ans[i] = "B"
          b += 1
          c -= 1
        else:
          ans[i] = "C"
          b -= 1
          c += 1
      
    if s[i] == "AC":
      if c == 0:
        ans[i] = "C"
        c += 1
        a -= 1
      elif a == 0:
        ans[i] = "A"
        c -= 1
        a += 1
      elif i != n-1 and s[i] != s[i+1]:
        if s[i+1] == "AB":
          ans[i] = "A"
          a += 1
          c -= 1
        if s[i+1] == "BC":
          ans[i] = "C"
          a -= 1
          c += 1
      else:
        if c < a:
          ans[i] = "C"
          c += 1
          a -= 1
        else:
          ans[i] = "A"
          c -= 1
          a += 1
  print("Yes")
  for i in range(n):
    print(ans[i])

def main():
    import sys
    input = sys.stdin.readline

    n, *abc = map(int, input().split())
    query = []
    for _ in [0] * n:
        s = input()
        query.append((ord(s[0]) - ord('A'), ord(s[1]) - ord('A')))
    query.append((0, 1)) # 番兵

    ans = ['A'] * n
    for i in range(n):
        a, b = query[i]
        if abc[a] == 0 and abc[b] == 0:
            print("No")
            return
        elif abc[a] == 0:
            abc[a] += 1
            abc[b] -= 1
            ans[i] = chr(ord('A') + a)
        elif abc[b] == 0:
            abc[a] -= 1
            abc[b] += 1
            ans[i] = chr(ord('A') + b)
        else:
            if a in query[i+1]:
                abc[a] += 1
                abc[b] -= 1
                ans[i] = chr(ord('A') + a)
            else:                
                abc[a] -= 1
                abc[b] += 1
                ans[i] = chr(ord('A') + b)
    print("Yes")
    print(*ans, sep=('\n'))

main()