Harryxun/stf_run huggingface dataset:
l=input().split()
r=int(l[0])
c=int(l[1])

# for yoko
i=0
b=[]
while i<r:
    a=input().split()
    q=0
    su=0
    while q<c:
        b.append(int(a[q]))
        su+=int(a[q])
        q=q+1
    b.append(su)
    i=i+1

# for tate
#x=0
#d=b[0]+b[c+1]+b[2*(c+1)]+b[3*(c+1)]
#x<c+1
x=0
while x<c+1:
    d=0
    d=b[x]+b[x+c+1]+b[x+2*(c+1)]+b[x+3*(c+1)]
    b.append(d)
    x=x+1
# for output
# C=[]
# y=0 (for gyou)
# z=0 (for yoko)
C=[]
y=0
while y<r+1:
    z=0
    Ans=str(b[y*(c+1)+z])
    while z<c:
        z+=1
        Ans=Ans+" "+str(b[y*(c+1)+z])
    C.append(Ans)
    y+=1

for k in C:
    print(k)



### FIXED CODE ###

l=input().split()
r=int(l[0])
c=int(l[1])

# for yoko
i=0
b=[]
while i<r:
    a=input().split()
    q=0
    su=0
    while q<c:
        b.append(int(a[q]))
        su+=int(a[q])
        q=q+1
    b.append(su)
    i=i+1

# for tate
#x=0
#d=b[0]+b[c+1]+b[2*(c+1)]+b[3*(c+1)]
#x<c+1
x=0
while x<c+1:
    d=0
    z=0
    while z<r:
        d+=b[x+z*(c+1)]
        z+=1
    b.append(d)
    x=x+1
# for output
# C=[]
# y=0 (for gyou)
# z=0 (for yoko)
C=[]
y=0
while y<r+1:
    z=0
    Ans=str(b[y*(c+1)+z])
    while z<c:
        z+=1
        Ans=Ans+" "+str(b[y*(c+1)+z])
    C.append(Ans)
    y+=1

for k in C:
    print(k)
s = input()
for i in range(len(s)):
  if s[i] == "1":
    s[i]="9"
  elif s[i]=="9":
    s[i]="1"
print(s)

### FIXED CODE ###

s = input()
s_list=list(s)
for i in range(len(s)):
  if s[i] == "1":
    s_list[i]='9'
  elif s[i]=="9":
    s_list[i]='1'
str_changed="".join(s_list)
print(str_changed)
def f(i,li,dp,visited):
    if(visited[i]==1):
        return dp[i]
    if(i>=len(li)):
        return 0
    if(i==len(li)-1):
        return 0
    if(i==len(li)-2):
        visited[i]=1
        dp[i]=abs(li[i]-li[i+1])
        return dp[i]
    else:
        dp[i]=min(f(i+1,li,dp,visited)+abs(li[i+1]-li[i]),f(i+2,li,dp,visited)+abs(li[i+2]-li[i]))
        visited[i]=1
        return dp[i]

n=int(input())
l=input().split()
li=[int(i) for i in l]
dp=[0 for i in range(n)]
visited=list(dp)
print(f(0,li,dp,visited))


### FIXED CODE ###

n=int(input())
l=input().split()
li=[int(i) for i in l]
dp=[0 for i in range(n)]
dp[0]=0
for i in range(1,n):
	if(i==1):
		dp[i]=dp[i-1]+abs(li[i]-li[i-1])
	else:
		dp[i]=min(dp[i-1]+abs(li[i]-li[i-1]),dp[i-2]+abs(li[i]-li[i-2]))
print(dp[-1])
A op B = input().split()
if op == "+":
  print(int(A)+int(B))
else:
  print(int(A)-int(B))

### FIXED CODE ###

A, op, B = input().split()
if op == "+":
  print(int(A)+int(B))
else:
  print(int(A)-int(B))
K = int(input())
X, Y = map(int, input().split())

def move(a, b, _a, _b, _s):
    # x, y > 0 and x < y
    if a < 0: 
        return move(-a, b, -1, _b, _s)
    if b < 0:
        return move(a, -b, _a, -1, _s)
    if a > b:
        return move(b, a, _b, _a, True)
    # ここから移動処理
    if a + b == K:
        return (0, 0)
    
    if a + b >= 2*K:
        ret = (a, b-K)
    else:
        r = K - (a + b)//2
        ret = (-r, b-K+a+r)
    # 後処理
    ret = _a * ret[0], _b * ret[1]
    ret = (ret[1], ret[0]) if _s else ret
    return ret

x, y = X, Y

if K % 2 == 0 and (x+y) % 2:
    print(-1)
else:
    ANS = []
    while x != 0 and y != 0:
        ANS.append((x, y))
        x, y = move(x, y, 1, 1, False)
    print(len(ANS))
    for ans in ANS[::-1]:
        print(ans[0], ans[1])

### FIXED CODE ###

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

K = (A + B) / 2

if A == B:
    print(0)
elif K.is_integer():
    print(int(K))
else:
    print('IMPOSSIBLE')
def BS(th, a):
    top = len(th)
    btm = 0

    while top > btm:
        mid = (top + btm)//2
        if th[mid] <= a < th[mid + 1]:
            return mid
        elif a <= th[mid]:
            top = mid
        else:
            btm = mid

N = int(input())
A = [int(i) for i in input().split()]

th = [0]
num_th = []
rem = []
max_i = 0
nonzeros = dict()

for i, a in enumerate(A):
    if a > th[-1]:
        th.append(a)
        num_th.append(1)
        rem.append(0)
        nonzeros[i] = max_i
        max_i += 1
    else:
        j = BS(th, a)
        if j - 1 >= 0:
            num_th[j - 1] += 1
        rem[j] += a - th[j]

for i in range(len(num_th) - 1, 0, -1):
    num_th[i - 1] += num_th[i]
'''
print(th)
print(num_th)
print(rem)
'''
for i in range(N):
    if i in nonzeros:
        ans = (th[nonzeros[i] + 1] - th[nonzeros[i]])*num_th[nonzeros[i]] + rem[nonzeros[i]]
        print(ans)
    else:
        print(0)

### FIXED CODE ###


def BS(th, a):
    top = len(th)
    btm = 0

    while top > btm:
        mid = (top + btm)//2
        if th[mid] < a <= th[mid + 1]:
            return mid
        elif a <= th[mid]:
            top = mid
        else:
            btm = mid

N = int(input())
A = [int(i) for i in input().split()]

th = [0]
num_th = []
rem = []
max_i = 0
nonzeros = dict()

for i, a in enumerate(A):
    if a > th[-1]:
        th.append(a)
        num_th.append(1)
        rem.append(0)
        nonzeros[i] = max_i
        max_i += 1
    else:
        j = BS(th, a)
        if j - 1 >= 0:
            num_th[j - 1] += 1
        rem[j] += a - th[j]

for i in range(len(num_th) - 1, 0, -1):
    num_th[i - 1] += num_th[i]
'''
print(th)
print(num_th)
print(rem)
'''
for i in range(N):
    if i in nonzeros:
        ans = (th[nonzeros[i] + 1] - th[nonzeros[i]])*num_th[nonzeros[i]] + rem[nonzeros[i]]
        print(ans)
    else:
        print(0)
from typing import List


class Work:
    require = 0
    limit = 0
    def __init__(self, require, limit) -> None:
        self.require = require
        self.limit = limit

def from_list(xs: List[int]) -> Work: 
    return Work(xs[0], xs[1])

N = int(input())

works = [from_list([int(_) for _ in input().split()]) for i in range(N)]

def solve(works):
    works.sort(key=lambda x: x.limit)
    acc = 0
    for w in works:
        acc += w.require
        if acc > w.limit:
            return "No"
    return "Yes"

print(solve(works))

### FIXED CODE ###

N = int(input())

Works = [dict(zip(["require", "limit"], [int(_) for _ in input().split()])) for i in range(N)]

def solve(Works):
    Works.sort(key=lambda x: x["limit"])
    acc = 0
    for w in Works:
        acc += w["require"]
        if acc > w["limit"]:
            return "No"
    return "Yes"

print(solve(Works))
import numpy as np
N=int(input())
H=np.array(list(map(int,input().split())))
diffH = np.diff(H)
if np.any((diffH[range(N-2)] + diffH[range(1, N-1)]) <= -2):
  print("No")
 
print("Yes")

### FIXED CODE ###

import numpy as np
N = int(input())
H = list(map(int, input().split()))

max = 0
for i in range(N):
  if max < H[i]:
    max = H[i]
  if max - H[i] >= 2:
    print("No")
    exit(0)
print("Yes")
x=int(input())
if(x==1):
  print("0")
 elif(x==0):
  print("1")
 else:
  pass

### FIXED CODE ###

x=int(input())
if(x==1):
  
  print("0")
elif(x==0):
  
  print("1")
else:
  
  pass
n = int(input())
A = list(map(int, input().split()))

# TLE
# l = []
# for i, a in enumerate(A):
#     if i%2 == 0:
#         l.append(a)
#     else:
#         l.insert(0, a)
# print(' '.join(map(str, l)))

print(*A[::-2], *A[n%2::2])

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
print(' '.join(map(str, A[::-2])), ' '.join(map(str, A[n%2::2])))
n=input()
m=input()
if int(n)==int(m):
  print('yes')
else:
  print('no')


### FIXED CODE ###

a=input()
b=a.split()
if int(b[0])==int(b[1]):
  print('Yes')
else:
  print('No')
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
N = int(input())
i, j = 1, 1
l = make_divisors(N)
len_l = len(l)
if len_l % 2 == 1:
    idx = (len_l-1)/2
    print((l[idx]-i) + (l[idx]-j))
else:
    idx = int(len_l / 2)
    print(sum(l[idx-1:idx+1])-2)


### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
N = int(input())
i, j = 1, 1
l = make_divisors(N)
len_l = len(l)
if len_l % 2 == 1:
    idx = int((len_l-1)/2)
    print((l[idx]-i) + (l[idx]-j))
else:
    idx = int(len_l / 2)
    print(sum(l[idx-1:idx+1])-2)
s = list(x for x in input())
temp = 0
ans = []
for i in s:
  if i == 'A' or i == 'C' or i =='G' or i =='T':
    temp += 1
    if i == len(s-1):
      ans.append(temp)
  else:
    ans.append(temp)
    temp = 0
print(max(ans))


### FIXED CODE ###

s = list(x for x in input())
temp = 0
ans = []
for i in range(len(s)):
  if s[i] == 'A' or s[i] == 'C' or s[i] =='G' or s[i] =='T':
    temp += 1
    if i == len(s) - 1:
      ans.append(temp)
  else:
    ans.append(temp)
    temp = 0
print(max(ans))
a,b,c=map(int,input().split())
x,y,z=sorted(a,b,c)
print('Yes' if x+y=z else 'No')

### FIXED CODE ###

a,b,c=sorted(map(int,input().split()))
print('Yes' if a+b==c else 'No')
n, m = [int(i) for i in input().split()]
p = [0 for i in range(m)]
y = [0 for i in range(m)]

out = [[0, 0] for i in range(m)]
hash = [[] for i in range(10**5)]
for i in range(m):
    p[i], y[i] = [int(i) for i in input().split()]
    hash[p[i]].append([y[i], i])

for i in range(len(hash)):
    hash[i] = sorted(hash[i])
    for j in range(len(hash[i])):
        out[hash[i][j][1]] = i, j+1
for i in range(len(out)):
    print("{}{}".format(str(out[i][0]).zfill(6), str(out[i][1]).zfill(6)))

### FIXED CODE ###

n, m = [int(i) for i in input().split()]
p = [0 for i in range(m)]
y = [0 for i in range(m)]

out = [[0, 0] for i in range(m)]
hash = [[] for i in range(10**5+10)]
for i in range(m):
    p[i], y[i] = [int(i) for i in input().split()]
    hash[p[i]].append([y[i], i])

for i in range(len(hash)):
    hash[i] = sorted(hash[i])
    for j in range(len(hash[i])):
        out[hash[i][j][1]] = i, j+1
for i in range(len(out)):
    print("{}{}".format(str(out[i][0]).zfill(6), str(out[i][1]).zfill(6)))
a = int(input().split())
if a[0]=a[-1]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

a=input()
if a[0]==a[2]:
  print("Yes")
else:
  print("No")
import math

def prime_factorize(n):
    ret = []
    while n % 2 == 0:
        ret.append(2)
        n //= 2
    div = 3
    while div <= math.sqrt(n):
        if n % div == 0:
            ret.append(div)
            n //= div
        else:
            div += 2
    if n != 1:
        ret.append(n)
    return ret


if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = set(prime_factorize(gcd))
    print(len(facts) + 1)

### FIXED CODE ###

import math
import fractions
gcd = math.gcd if hasattr(math, "gcd") else fractions.gcd

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

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

g = gcd(A, B)

print(len(set(factorize(g)))+1)
n = input()
print(n ** 3)

### FIXED CODE ###

n = input()
print(int(n) ** 3)
import queue
def dijkstra(n,EdgeMatrix,start):

    NodeList=queue.PriorityQueue() #探索対象の頂点
    Distance=[float('inf')]*n #頂点0からの最短経路
    used=[False]*n #頂点の使用情報

    Distance[start]=0 #0から0までの距離は0
    used[start]=True #0から探索を始める
    LastNode=start #最新の頂点
    count=1 #つないだ頂点の数

    while count<n:
        for i in range(len(EdgeMatrix[LastNode])):
            #探索していない頂点へ距離の短い辺があればキューに追加
            Edge=EdgeMatrix[LastNode][i]
            if used[Edge[0]]==False and Distance[Edge[0]]>Distance[LastNode]+Edge[1]:
                    Distance[Edge[0]]=Distance[LastNode]+Edge[1]
                    NodeList.put([Distance[Edge[0]],Edge[0]])

        #最も近い探索していない頂点
        while True:
            minNode=NodeList.get()
            if used[minNode[1]]==False:
                break

        LastNode=minNode[1] #最新の頂点を更新
        used[minNode[1]]=True #頂点の使用情報を更新
        count+=1 #つないだ頂点の数を更新
    return Distance

#入力
n,m,s=map(int,input().split())

#辺の隣接リスト
EdgeMatrix=[[] for i in range(125000)]

for i in range(m):
    u,v,a,b=map(int,input().split())
    for j in range(a,2500):
        EdgeMatrix[(u-1)*2500+j].append([(v-1)*2500+j-a,b])
        EdgeMatrix[(v-1)*2500+j].append([(u-1)*2500+j-a,b])

for i in range(n):
    c,d=map(int,input().split())
    for j in range(2450):
        EdgeMatrix[i*2500+j].append([min(i*2500+j+c,(i+1)*2500-1),d])

#頂点0からの最短経路
Distance=dijkstra(125000,EdgeMatrix,s)

for i in range(1,n):
    print(min(Distance[i*2500:(i+1)*2500-1]))


### FIXED CODE ###

import queue
def dijkstra(n,EdgeMatrix,start):

    NodeList=queue.PriorityQueue() #探索対象の頂点
    Distance=[float('inf')]*n #頂点0からの最短経路
    used=[False]*n #頂点の使用情報

    Distance[start]=0 #0から0までの距離は0
    used[start]=True #0から探索を始める
    LastNode=start #最新の頂点
    NodeList.put([0,start])
    Flag=True #探索対象がなくなるとFalse
    
    while Flag:
        Flag=False
        for i in range(len(EdgeMatrix[LastNode])):
            #探索していない頂点へ距離の短い辺があればキューに追加
            Edge=EdgeMatrix[LastNode][i]
            if used[Edge[0]]==False and Distance[Edge[0]]>Distance[LastNode]+Edge[1]:
                    Distance[Edge[0]]=Distance[LastNode]+Edge[1]
                    NodeList.put([Distance[Edge[0]],Edge[0]])

        #最も近い探索していない頂点
        while not NodeList.empty():
            minNode=NodeList.get()
            if used[minNode[1]]==False:
                Flag=True
                break

        LastNode=minNode[1] #最新の頂点を更新
        used[minNode[1]]=True #頂点の使用情報を更新
    return Distance

#入力
n,m,s=map(int,input().split())

#辺の隣接リスト
EdgeMatrix=[[] for i in range(125000)]

for i in range(m):
    u,v,a,b=map(int,input().split())
    for j in range(a,2500):
        EdgeMatrix[(u-1)*2500+j].append([(v-1)*2500+j-a,b])
        EdgeMatrix[(v-1)*2500+j].append([(u-1)*2500+j-a,b])

for i in range(n):
    c,d=map(int,input().split())
    for j in range(2450):
        EdgeMatrix[i*2500+j].append([min(i*2500+j+c,(i+1)*2500-1),d])

#for i in range(2502):
#    print(EdgeMatrix[i])
    
#頂点0からの最短経路
Distance=dijkstra(125000,EdgeMatrix,min(s,2499))

for i in range(1,n):
    print(min(Distance[i*2500:(i+1)*2500-1]))
s = list(input())
N = len(s)
c=0
for i in range(N-1):
  if s[i]=s[N-1-i] and s[i]=s[(N-1)/2-1-i] and s[(N+3)/2-1+i]=s[N-1-i]:
    c+=1
    
if c == N:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = list(input())
n = (len(s)+1)//2
if s[:n-1] == s[len(s):n-1:-1] == s[n-2::-1]:
  print("Yes")
else:
  print("No")
#Python

A = map(int, raw_input().split())
if A[0]+A[1]>=10:
	print ‘error’
else:
	print A[0]+A[1]

### FIXED CODE ###

#Python

A = map(int, raw_input().split())
if A[0]+A[1]>=10:
	print 'error'
else:
	print A[0]+A[1]
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
cnt = 0
for k in [a,b,c]:
    ans = 0
    for i in range(1, 257):
        s = 0
        for j in range(n):
            if i & 2**j:
                if s > 0:
                    s += 10
                s += l[j]
        v = abs(k - s)
        if v < ans:
            ans = v
            x = i
    cnt += ans
    for j in range(n):
        if x & 2**j:
            l[j] = 0
print(cnt)

### FIXED CODE ###

n,a,b,c = map(int, input().split())
l = [int(input()) for _ in range(n)]
def dfs(k,p,q,r):
  if k == n:
    if min(p,q,r) > 0:
      return abs(p-a)+abs(q-b)+abs(r-c)-30
    else:
      return 10**7
  t1 = dfs(k+1,p,q,r)
  t2 = dfs(k+1,p+l[k],q,r)+10
  t3 = dfs(k+1,p,q+l[k],r)+10
  t4 = dfs(k+1,p,q,r+l[k])+10
  return min(t1,t2,t3,t4)

print(dfs(0,0,0,0))
N = int(input())
a = [int(input()) for i in range(N)]

print("Yes" if max(a) > sum(a)-max(a) else "No")


### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))

print("Yes" if max(a) < sum(a)-max(a) else "No")
miss

### FIXED CODE ###

h, w = map(int, input().split())
a = [input() for _ in range(h)]
row = [False] * h
col = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end='')
        print()
from sys import stdin
import numpy as np


def merge_sort(lst, low, high):
    if low >= high:
        return
    mid = int((low+high)/2)
    merge_sort(lst, low, mid)
    merge_sort(lst, mid+1, high)
    for i in range(low, mid+1):
        tmp_array[i] = lst[i]
    j = high
    for i in range(mid+1, high+1):
        tmp_array[i] = lst[j]
        j -= 1
    i = low
    j = high
    for k in range(low, high+1):
        if tmp_array[i] <= tmp_array[j]:
            lst[k] = tmp_array[i]
            i += 1
        else:
            lst[k] = tmp_array[j]
            j -= 1


S = stdin.readline().rstrip()
N = len(S)
Sp = S

res_map = [0 for _ in range(N)]

aa_list2 = [1]
for i in range(1,N):
    aa_list2.append((aa_list2[i-1]*10)%2019)

tmp_array = [None for _ in range(N)]
res_map[N-1] = int(S[N-1])
index=1
for i in range(N-2,-1,-1):
    res_map[i] = (int(S[i])*aa_list2[index] + res_map[i+1])%2019
    index+=1
#merge_sort(res_map,0,N-1)
#res_map = list(np.sort(np.array(res_map)))
res_map.sort()
temp_num=int(res_map[0])
index=1
tot = 0

#for i in range(1,N):
#    if temp_num==res_map[i]:
#        index+=1
#        continue
#    else:
#        if temp_num==0:
#            tot += int(index*(index+1)/2)
#        elif index>1:
#            tot += int(index*(index-1)/2)
#            #tot += index/2
#        index=1
#        temp_num=res_map[i]


for i in range(2018):
    num = np.sum(np.array(res_map)==i)
    if i ==0:
        num+=1
    tot += int(num*(num-1)/2)
    

print(tot)



### FIXED CODE ###

from sys import stdin

S = stdin.readline().rstrip()
N = len(S)
Sp = S

res_map = [0 for _ in range(N)]

aa_list2 = [1]
for i in range(1,N):
    aa_list2.append((aa_list2[i-1]*10)%2019)

res_map[N-1] = int(S[N-1])
index=1


for i in range(N-2,-1,-1):
    res_map[i] = (int(S[i])*aa_list2[index] + res_map[i+1])%2019
    index+=1

aa_table = [0 for i in range(2019)]
for i in range(len(res_map)):
    aa_table[res_map[i]]+=1

aa_table[0]+=1

tot = 0
for i in range(2019):
    tot+=int((aa_table[i]-1)*aa_table[i]/2)

print(tot)
import itertools
S=input()
T=input()

def insert_hint(item,hintindex,S):
  for i in hintindex:
    item.insert(i,S[i])
  return item
  
hintindex=[n for _,n in enumerate(range(len(S))) if S[n]!="?"]

zenbu=list(itertools.permutations(
  list("abcdefghijklmnopqrstuvwxyz"),
  len(S)-len(hintindex)
))
zenbu=[insert_hint(list(item),hintindex,S) for item in zenbu]
#print(zenbu[-1])

anslist=[item for item in zenbu if "".join(item).find(T)!=-1]

#print(anslist)
print("".join(sorted(anslist)[0]))

### FIXED CODE ###

import re
S = input().replace('?', '.')
T = input()
for i in range(len(S)-len(T), -1, -1):
    if re.match(S[i:i+len(T)], T):
        S = S.replace('.', 'a')
        print(S[:i]+T+S[i+len(T):])
        exit()
print('UNRESTORABLE')
n, A, B, C = map(int, input().split())
s = [list(input()) for _ in range(n)]

cur = dict()
cur['A'], cur['B'], cur['C'] = A, B, C

counts = dict()
counts['AB'], counts['AC'], counts['BC'] = 0, 0, 0
for ss in s:
    counts[''.join(ss)] += 1

f = True
ans = []
for i, ss in enumerate(s):
    if cur[ss[0]] == 1 and cur[ss[1]] == 1 and sorted(list(cur.values())) == [0, 1, 1] and i < len(s):
        if ss[0] in s[i + 1]:
            cur[ss[0]] += 1
            cur[ss[1]] -= 1
            ans.append(ss[0])
        elif ss[1] in s[i + 1]:
            cur[ss[1]] += 1
            cur[ss[0]] -= 1
            ans.append(ss[1])

    else:
        if cur[ss[0]] >= cur[ss[1]]:
            cur[ss[0]] -= 1
            cur[ss[1]] += 1
            ans.append(ss[1])
        else:
            cur[ss[0]] += 1
            cur[ss[1]] -= 1
            ans.append(ss[0])

    if -1 in list(cur.values()):
        f = False
        break

if f:
    print('Yes')
    for a in ans:
        print(a)
else:
    print('No')


### FIXED CODE ###

n, A, B, C = map(int, input().split())
s = [list(input()) for _ in range(n)]

cur = dict()
cur['A'], cur['B'], cur['C'] = A, B, C

f = True
ans = []
for i, ss in enumerate(s):
    if cur[ss[0]] == 1 and cur[ss[1]] == 1 and sorted(list(cur.values())) == [0, 1, 1] and i < len(s) - 1:
        if ss[0] in s[i + 1]:
            cur[ss[0]] += 1
            cur[ss[1]] -= 1
            ans.append(ss[0])
        elif ss[1] in s[i + 1]:
            cur[ss[1]] += 1
            cur[ss[0]] -= 1
            ans.append(ss[1])

    else:
        if cur[ss[0]] >= cur[ss[1]]:
            cur[ss[0]] -= 1
            cur[ss[1]] += 1
            ans.append(ss[1])
        else:
            cur[ss[0]] += 1
            cur[ss[1]] -= 1
            ans.append(ss[0])

    if -1 in list(cur.values()):
        f = False
        break

if f:
    print('Yes')
    for a in ans:
        print(a)
else:
    print('No')
N, M, K = map(int, input().split())
a_timelist = int(input().split())
b_timelist = int(input().split())
counta = len(a_timelist)
countb = len(b_timelist)
time = 0
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + a_timelist[i])
for i in range(M):
  b.append(b[i] + b_timelist[i])
ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[i] > K -a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)
N, M, K = int(input().split())
a_timelist = int(input().split())
b_timelist = int(input().split())
counta = len(a_timelist)
countb = len(b_timelist)
time = 0
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + a_timelist[i])
for i in range(M):
  b.append(b[i] + b_timelist[i])
ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[i] > K -a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)
提出情報

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)