def solve(writer):

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

    variables = {

        'A': A,

        'B': B,

        'C': C

    }



    queries = (list(eval(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')





if __name__ == "__main__":

    main()

import sys

readline = sys.stdin.readline





def solve(writer):

    N, A, B, C = 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')





if __name__ == "__main__":

    main()

def solve(writer):
    N, A, B, C = list(map(int, input().split()))
    variables = {"A": A, "B": B, "C": C}
    queries = (list(eval(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")


if __name__ == "__main__":
    main()

import sys

readline = sys.stdin.readline


def solve(writer):
    N, A, B, C = 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")


if __name__ == "__main__":
    main()

+import sys + +readline = sys.stdin.readline + + -    N, A, B, C = list(map(int, input().split())) +    N, A, B, C = map(int, input().split()) -    queries = (list(eval(input())) for _ in range(N)) -    buffer = list() +    queries = (list(readline().strip()) for _ in range(N)) +    next_q = next(queries) -        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: +        let_1, let_2 = next_q +        next_q = next(queries) if i != N - 1 else () +        if variables[let_1] == variables[let_2] == 0: -        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) +        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) -    writer = list() +    writer = ["Yes"] -        print("Yes")