import sys

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



def main():

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

    s = tuple(input() for _ in range(N))

    d = {}

    d["A"] = A

    d["B"] = B

    d["C"] = C

    ans = []

    for i in range(N-1):

        l1, r1 = s[i]

        l2, r2 = s[i+1]



        if d["A"]*d["B"]*d["C"]:

            temp = [d[l1], d[r1]]

            max_val = max(temp)

            max_index = temp.index(max_val)

            

            if max_index == 0:

                ans.append(r1)

                d[l1] -= 1

                d[r1] += 1

            else:

                ans.append(l1)

                d[l1] += 1

                d[r1] -= 1

        else:

            if d[l1] * d[r1]:

                if l1 == l2 and r1 == r2:

                    ans.append(l1)

                    d[l1] += 1

                    d[r1] -= 1

                else:

                    for c in [l1, r1]:

                        if [l1, r1, l2, r2].count(c) == 1:

                            d[c] -= 1

                        else:

                            ans.append(c)

                            d[c] += 1

            else:

                temp = [d[l1], d[r1]]

                max_val = max(temp)

                max_index = temp.index(max_val)

            

                if max_index == 0:

                    ans.append(r1)

                    d[l1] -= 1

                    d[r1] += 1

                else:

                    ans.append(l1)

                    d[l1] += 1

                    d[r1] -= 1

        if any([d[c] < 0 for c in "ABC"]):

            print("No")

            exit()



    l1, r1 = s[N-1]

    temp = [d[l1], d[r1]]

    max_val = max(temp)

    max_index = temp.index(max_val)

            

    if max_index == 0:

        ans.append(r1)

        d[l1] -= 1

        d[r1] += 1

    else:

        ans.append(l1)

        d[l1] += 1

        d[r1] -= 1



    if any([d[c] < 0 for c in "ABC"]):

            print("No")

    else:

        print("Yes")

        print(*ans, sep="\n")



if __name__ == "__main__":

    main()

import sys

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



def main():

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

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

    d = {}

    d["A"] = A

    d["B"] = B

    d["C"] = C

    

    ans = []

    s.append("XX")

    for i in range(N):

        l1, r1 = s[i]

        l2, r2 = s[i+1]



        def func(a, b):

            d[a] += 1

            d[b] -= 1

            ans.append(a)



        if d[l1] == 0 and d[r1] == 0:

            print("No")

            exit()

        

        if d[l1] == 0:

            func(l1, r1)

        elif d[r1] == 0:

            func(r1, l1)

        else:

            if l1 in [l2, r2]:

                func(l1, r1)

            else:

                func(r1, l1)



    print("Yes")

    print(*ans, sep="\n")



if __name__ == "__main__":

    main()

import sys


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


def main():
    N, A, B, C = map(int, input().split())
    s = tuple(input() for _ in range(N))
    d = {}
    d["A"] = A
    d["B"] = B
    d["C"] = C
    ans = []
    for i in range(N - 1):
        l1, r1 = s[i]
        l2, r2 = s[i + 1]
        if d["A"] * d["B"] * d["C"]:
            temp = [d[l1], d[r1]]
            max_val = max(temp)
            max_index = temp.index(max_val)
            if max_index == 0:
                ans.append(r1)
                d[l1] -= 1
                d[r1] += 1
            else:
                ans.append(l1)
                d[l1] += 1
                d[r1] -= 1
        else:
            if d[l1] * d[r1]:
                if l1 == l2 and r1 == r2:
                    ans.append(l1)
                    d[l1] += 1
                    d[r1] -= 1
                else:
                    for c in [l1, r1]:
                        if [l1, r1, l2, r2].count(c) == 1:
                            d[c] -= 1
                        else:
                            ans.append(c)
                            d[c] += 1
            else:
                temp = [d[l1], d[r1]]
                max_val = max(temp)
                max_index = temp.index(max_val)
                if max_index == 0:
                    ans.append(r1)
                    d[l1] -= 1
                    d[r1] += 1
                else:
                    ans.append(l1)
                    d[l1] += 1
                    d[r1] -= 1
        if any([d[c] < 0 for c in "ABC"]):
            print("No")
            exit()
    l1, r1 = s[N - 1]
    temp = [d[l1], d[r1]]
    max_val = max(temp)
    max_index = temp.index(max_val)
    if max_index == 0:
        ans.append(r1)
        d[l1] -= 1
        d[r1] += 1
    else:
        ans.append(l1)
        d[l1] += 1
        d[r1] -= 1
    if any([d[c] < 0 for c in "ABC"]):
        print("No")
    else:
        print("Yes")
        print(*ans, sep="\n")


if __name__ == "__main__":
    main()

import sys


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


def main():
    N, A, B, C = map(int, input().split())
    s = list(input() for _ in range(N))
    d = {}
    d["A"] = A
    d["B"] = B
    d["C"] = C
    ans = []
    s.append("XX")
    for i in range(N):
        l1, r1 = s[i]
        l2, r2 = s[i + 1]

        def func(a, b):
            d[a] += 1
            d[b] -= 1
            ans.append(a)

        if d[l1] == 0 and d[r1] == 0:
            print("No")
            exit()
        if d[l1] == 0:
            func(l1, r1)
        elif d[r1] == 0:
            func(r1, l1)
        else:
            if l1 in [l2, r2]:
                func(l1, r1)
            else:
                func(r1, l1)
    print("Yes")
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

-    s = tuple(input() for _ in range(N)) +    s = list(input() for _ in range(N)) -    for i in range(N - 1): +    s.append("XX") +    for i in range(N): -        if d["A"] * d["B"] * d["C"]: -            temp = [d[l1], d[r1]] -            max_val = max(temp) -            max_index = temp.index(max_val) -            if max_index == 0: -                ans.append(r1) -                d[l1] -= 1 -                d[r1] += 1 -            else: -                ans.append(l1) -                d[l1] += 1 -                d[r1] -= 1 -        else: -            if d[l1] * d[r1]: -                if l1 == l2 and r1 == r2: -                    ans.append(l1) -                    d[l1] += 1 -                    d[r1] -= 1 -                else: -                    for c in [l1, r1]: -                        if [l1, r1, l2, r2].count(c) == 1: -                            d[c] -= 1 -                        else: -                            ans.append(c) -                            d[c] += 1 -            else: -                temp = [d[l1], d[r1]] -                max_val = max(temp) -                max_index = temp.index(max_val) -                if max_index == 0: -                    ans.append(r1) -                    d[l1] -= 1 -                    d[r1] += 1 -                else: -                    ans.append(l1) -                    d[l1] += 1 -                    d[r1] -= 1 -        if any([d[c] < 0 for c in "ABC"]): + +        def func(a, b): +            d[a] += 1 +            d[b] -= 1 +            ans.append(a) + +        if d[l1] == 0 and d[r1] == 0: -    l1, r1 = s[N - 1] -    temp = [d[l1], d[r1]] -    max_val = max(temp) -    max_index = temp.index(max_val) -    if max_index == 0: -        ans.append(r1) -        d[l1] -= 1 -        d[r1] += 1 -    else: -        ans.append(l1) -        d[l1] += 1 -        d[r1] -= 1 -    if any([d[c] < 0 for c in "ABC"]): -        print("No") -    else: -        print("Yes") -        print(*ans, sep="\n") +        if d[l1] == 0: +            func(l1, r1) +        elif d[r1] == 0: +            func(r1, l1) +        else: +            if l1 in [l2, r2]: +                func(l1, r1) +            else: +                func(r1, l1) +    print("Yes") +    print(*ans, sep="\n")