#!/usr/bin/env python3

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

import sys



YES = "Yes"  # type: str

NO = "No"  # type: str





def solve(N: int, A: int, B: int, C: int, s: "List[int]"):

    v = [A, B, C]

    ans = []

    if sum(v) == 0:

        return None

    if sum(v) == 1:

        for l, r in s:

            if v[l] + v[r] == 0:

                return None

            if v[l] == 0:

                ans.append(l)

            else:

                ans.append(r)

            v[l], v[r] = v[r], v[l]

        return ans

    if sum(v) > 1:

        for i in range(N):

            l, r = s[i]

            if v[l] + v[r] == 0:

                return None

            if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]:

                ans.append(r)

                v[l] -= 1

                v[r] += 1

            else:

                ans.append(l)

                v[l] += 1

                v[r] -= 1

        return ans





def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word



    def s2i(s: str):

        return ord(s[0])-ord('A'), ord(s[1])-ord('A')



    def i2s(i: int):

        return chr(i + ord('A'))



    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    A = int(next(tokens))  # type: int

    B = int(next(tokens))  # type: int

    C = int(next(tokens))  # type: int

    s = [s2i(next(tokens)) for _ in range(N)]  # type: "List[int]"

    ans = solve(N, A, B, C, s)

    if ans == None:

        print(NO)

    else:

        print(YES)

        print(("\n".join(list(map(i2s, ans)))))





if __name__ == '__main__':

    main()

#!/usr/bin/env python3

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

import sys



YES = "Yes"  # type: str

NO = "No"  # type: str





def solve(N: int, A: int, B: int, C: int, s: "List[int]"):

    v = [A, B, C]

    ans = []

    for i in range(N):

        l, r = s[i]

        if v[l] + v[r] == 0:

            return None

        if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]:

            ans.append(r)

            v[l] -= 1

            v[r] += 1

        else:

            ans.append(l)

            v[l] += 1

            v[r] -= 1

    return ans





def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word



    def s2index(s: "List[str]"):

        return [ord(c)-ord('A') for c in s]



    def index2s(i: int):

        return chr(i + ord('A'))



    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    A = int(next(tokens))  # type: int

    B = int(next(tokens))  # type: int

    C = int(next(tokens))  # type: int

    s = [s2index(next(tokens)) for _ in range(N)]  # type: "List[int]"

    ans = solve(N, A, B, C, s)



    if ans == None:

        print(NO)

    else:

        print(YES)

        print(("\n".join(list(map(index2s, ans)))))





if __name__ == '__main__':

    main()

#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: int, B: int, C: int, s: "List[int]"):
    v = [A, B, C]
    ans = []
    if sum(v) == 0:
        return None
    if sum(v) == 1:
        for l, r in s:
            if v[l] + v[r] == 0:
                return None
            if v[l] == 0:
                ans.append(l)
            else:
                ans.append(r)
            v[l], v[r] = v[r], v[l]
        return ans
    if sum(v) > 1:
        for i in range(N):
            l, r = s[i]
            if v[l] + v[r] == 0:
                return None
            if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]:
                ans.append(r)
                v[l] -= 1
                v[r] += 1
            else:
                ans.append(l)
                v[l] += 1
                v[r] -= 1
        return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    def s2i(s: str):
        return ord(s[0]) - ord("A"), ord(s[1]) - ord("A")

    def i2s(i: int):
        return chr(i + ord("A"))

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [s2i(next(tokens)) for _ in range(N)]  # type: "List[int]"
    ans = solve(N, A, B, C, s)
    if ans == None:
        print(NO)
    else:
        print(YES)
        print(("\n".join(list(map(i2s, ans)))))


if __name__ == "__main__":
    main()

#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: int, B: int, C: int, s: "List[int]"):
    v = [A, B, C]
    ans = []
    for i in range(N):
        l, r = s[i]
        if v[l] + v[r] == 0:
            return None
        if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]:
            ans.append(r)
            v[l] -= 1
            v[r] += 1
        else:
            ans.append(l)
            v[l] += 1
            v[r] -= 1
    return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    def s2index(s: "List[str]"):
        return [ord(c) - ord("A") for c in s]

    def index2s(i: int):
        return chr(i + ord("A"))

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [s2index(next(tokens)) for _ in range(N)]  # type: "List[int]"
    ans = solve(N, A, B, C, s)
    if ans == None:
        print(NO)
    else:
        print(YES)
        print(("\n".join(list(map(index2s, ans)))))


if __name__ == "__main__":
    main()

-    if sum(v) == 0: -        return None -    if sum(v) == 1: -        for l, r in s: -            if v[l] + v[r] == 0: -                return None -            if v[l] == 0: -                ans.append(l) -            else: -                ans.append(r) -            v[l], v[r] = v[r], v[l] -        return ans -    if sum(v) > 1: -        for i in range(N): -            l, r = s[i] -            if v[l] + v[r] == 0: -                return None -            if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]: -                ans.append(r) -                v[l] -= 1 -                v[r] += 1 -            else: -                ans.append(l) -                v[l] += 1 -                v[r] -= 1 -        return ans +    for i in range(N): +        l, r = s[i] +        if v[l] + v[r] == 0: +            return None +        if v[r] == 0 or v[l] >= v[r] and i != N - 1 and r in s[i + 1]: +            ans.append(r) +            v[l] -= 1 +            v[r] += 1 +        else: +            ans.append(l) +            v[l] += 1 +            v[r] -= 1 +    return ans -    def s2i(s: str): -        return ord(s[0]) - ord("A"), ord(s[1]) - ord("A") +    def s2index(s: "List[str]"): +        return [ord(c) - ord("A") for c in s] -    def i2s(i: int): +    def index2s(i: int): -    s = [s2i(next(tokens)) for _ in range(N)]  # type: "List[int]" +    s = [s2index(next(tokens)) for _ in range(N)]  # type: "List[int]" -        print(("\n".join(list(map(i2s, ans))))) +        print(("\n".join(list(map(index2s, ans)))))