def main():

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

    s = [list(eval(input())) for _ in range(n)]

    t = a+b+c

    d = dict(A=a, B=b, C=c)

    ans = []

    if t == 0:

        print("No")

        return

    if t == 1:

        for i in range(n):

            si = s[i]

            if d[si[0]] == 1:

                d[si[0]], d[si[1]] = 0, 1

                ans.append(si[1])

            elif d[si[1]] == 1:

                d[si[0]], d[si[1]] = 1, 0

                ans.append(si[0])

            else:

                print("No")

                return

        print("Yes")

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

    else:

        for i in range(n-1):

            si = s[i]

            sin = s[i+1]

            if d[si[0]] >= 1 and d[si[1]] >= 1:

                if si[0] in sin:

                    d[si[0]] += 1

                    d[si[1]] -= 1

                    ans.append(si[0])

                else:

                    d[si[0]] -= 1

                    d[si[1]] += 1

                    ans.append(si[1])

            elif d[si[0]] == 0 and d[si[1]] >= 1:

                d[si[0]] += 1

                d[si[1]] -= 1

                ans.append(si[0])

            elif d[si[0]] >= 1 and d[si[1]] == 0:

                d[si[0]] -= 1

                d[si[1]] += 1

                ans.append(si[1])

            else:

                print("No")

                return

        si = s[n-1]

        if d[si[0]] >= 1 and d[si[1]] >= 1:

            ans.append(si[0])

        elif d[si[0]] == 0 and d[si[1]] >= 1:

            ans.append(si[0])

        elif d[si[0]] >= 1 and d[si[1]] == 0:

            ans.append(si[1])

        else:

            print("No")

            return

        print("Yes")

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

        

        

        



if __name__ == "__main__":

    main()
def main():

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

    s = [list(eval(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



if __name__ == "__main__":

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


if __name__ == "__main__":
    main()

def main():
    n, a, b, c = list(map(int, input().split()))
    s = [list(eval(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


if __name__ == "__main__":
    main()

+    num = dict(A=a, B=b, C=c) -    d = dict(A=a, B=b, C=c) -            if d[si[0]] == 1: -                d[si[0]], d[si[1]] = 0, 1 +            if num[si[0]] == 1: +                num[si[0]] -= 1 +                num[si[1]] += 1 -            elif d[si[1]] == 1: -                d[si[0]], d[si[1]] = 1, 0 +            elif num[si[1]] == 1: +                num[si[0]] += 1 +                num[si[1]] -= 1 -    else: -        for i in range(n - 1): -            si = s[i] +        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: -            if d[si[0]] >= 1 and d[si[1]] >= 1: -                if si[0] in sin: -                    d[si[0]] += 1 -                    d[si[1]] -= 1 -                    ans.append(si[0]) -                else: -                    d[si[0]] -= 1 -                    d[si[1]] += 1 -                    ans.append(si[1]) -            elif d[si[0]] == 0 and d[si[1]] >= 1: -                d[si[0]] += 1 -                d[si[1]] -= 1 +            if si[0] in sin: +                num[si[0]] += 1 +                num[si[1]] -= 1 -            elif d[si[0]] >= 1 and d[si[1]] == 0: -                d[si[0]] -= 1 -                d[si[1]] += 1 +            else: +                num[si[0]] -= 1 +                num[si[1]] += 1 -            else: -                print("No") -                return -        si = s[n - 1] -        if d[si[0]] >= 1 and d[si[1]] >= 1: -            ans.append(si[0]) -        elif d[si[0]] == 0 and d[si[1]] >= 1: -            ans.append(si[0]) -        elif d[si[0]] >= 1 and d[si[1]] == 0: -            ans.append(si[1]) -        print("Yes") -        print(("\n".join(ans))) +    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