Problem:
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.

Incorrect submission (verdict: Wrong Answer):
n,a,b,c=map(int,input().split())
ab=0
ac=0
bc=0
for i in range(n):
    s=input()
    if s=="AB":
        ab+=1
    elif s=="AC":
        ac+=1
    else:
        bc+=1
ab2=ab%2
ac2=ac%2
bc2=bc%2
if ab2==1 and a+b==0:
    print("No")
elif ac2==1 and a+c==0:
    print("No")
elif bc2==1 and b+c==0:
    print("No")
elif ab2+ac2==2 and a+b+c<2:
    print("No")
elif ab2+bc2==2 and a+b+c<2:
    print("No")
elif bc2+ac2==2 and a+b+c<2:
    print("No")
elif ab2+ac2+bc2==3 and a+b+c<3:
    print("No")
else:
    print("Yes")


Fixed, accepted submission:
n,a,b,c=map(int,input().split())
ans=[]
slist=[]
for i in range(n):
    s=input()
    slist.append(s)
for i in range(n):
    s=slist[i]
    if s=="AB":
        if a==0:
            a+=1
            b-=1
            ans.append("A")
        elif b==0:
            a-=1
            b+=1
            ans.append("B")
        elif slist[(i+1)%n]=="AB":
            if a>b:
                a-=1
                b+=1
                ans.append("B")
            else:
                a+=1
                b-=1
                ans.append("A")
        elif slist[(i+1)%n]=="AC":
            a+=1
            b-=1
            ans.append("A")
        else:
            a-=1
            b+=1
            ans.append("B")
    elif s=="AC":
        if a==0:
            a+=1
            c-=1
            ans.append("A")
        elif c==0:
            a-=1
            c+=1
            ans.append("C")
        elif slist[(i+1)%n]=="AC":
            if a>c:
                a-=1
                c+=1
                ans.append("C")
            else:
                a+=1
                c-=1
                ans.append("A")
        elif slist[(i+1)%n]=="AB":
            a+=1
            c-=1
            ans.append("A")
        else:
            a-=1
            c+=1
            ans.append("C")
    else:
        if b==0:
            b+=1
            c-=1
            ans.append("B")
        elif c==0:
            b-=1
            c+=1
            ans.append("C")
        elif slist[(i+1)%n]=="BC":
            if b>c:
                b-=1
                c+=1
                ans.append("C")
            else:
                b+=1
                c-=1
                ans.append("B")
        elif slist[(i+1)%n]=="AC":
            c+=1
            b-=1
            ans.append("C")
        else:
            c-=1
            b+=1
            ans.append("B")
    if a<0 or b<0 or c<0:
        ans.clear()
        break
if len(ans)==0:
    print("No")
else:
    print("Yes")
    for i in range(n):
        print(ans[i])