Harryxun/stf_run huggingface dataset:
n = input()

S = range(1, 14)
H = range(1, 14)
C = range(1, 14)
D = range(1, 14)

for i in range(0, n):
   mk, num = raw_input().split()
      if mk == 'S':
         S[int(num)-1] = 0
      elif mk == 'H':
         H[int(num)-1] = 0
      elif mk == 'C':
         C[int(num)-1] = 0
      elif mk == 'D':
         D[int(num)-1] = 0

for i in range(0, 13):
   if S[i] != 0:
      print 'S '+ str(S[i])

for i in range(0, 13):
   if H[i] != 0:
      print 'H '+ str(H[i])

for i in range(0, 13):
   if C[i] != 0:
      print 'C '+ str(C[i])

for i in range(0,13):
   if D[i] != 0:
      print 'D '+ str(D[i])

### FIXED CODE ###

n=input()
  
s=range(1,14)
h=range(1,14)
c=range(1,14)
d=range(1,14)
   
for i in range(n):
   m, k=raw_input().split()
   if m == 'S':
      s[int(k)-1] = 0
   elif m == 'H':
      h[int(k)-1] = 0
   elif m == 'C':
      c[int(k)-1] = 0
   elif m == 'D':
      d[int(k)-1] = 0
  
for i in range(0, 13):
   if s[i] != 0:
      print 'S '+str(s[i])
  
for i in range(0, 13):
   if h[i] != 0:
      print 'H '+str(h[i])
  
for i in range(0, 13):
   if c[i] != 0:
      print 'C '+str(c[i])
  
for i in range(0, 13):
   if d[i] != 0:
      print 'D '+str(d[i])
import sys
N,M=map(int,input().split())
A=list(set(map(int,input().split())))
N=len(A)
A=[a//2 for a in A]

def f(x):
    cnt=0
    while x%2==0:
        x//=2
        cnt+=1
    return cnt

C=f(A[0])
for a in A:
    if f(a)!=C:
        print(0)
        sys.exit()
def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x

a1=A.pop()
a2=A.pop()
LCM=lcm(a1,a2)
while A!=[]:
    a2=A.pop()
    LCM=lcm(LCM,a2)
if LCM>M:
    ans=0
else:
    M//=LCM
    ans=(M+1)//2
print(ans)

### FIXED CODE ###

import sys
N,M=map(int,input().split())
A=list(set(map(int,input().split())))
N=len(A)
A=[a//2 for a in A]

def f(x):
    cnt=0
    while x%2==0:
        x//=2
        cnt+=1
    return cnt
C=f(A[0])
for a in A:
    if f(a)!=C:
        print(0)
        sys.exit()
def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x
LCM=A[0]
for i in range(1,N):
    LCM=lcm(LCM,A[i])
if LCM>M:
    ans=0
else:
    M//=LCM
    ans=(M+1)//2
print(ans)
import math

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    
    if K > 41
        K = 41
    
    for k in range(K):
        B = [0 for i in range(N)]
        for i in range(N):
            low = max(0,i-A[i])
            high = min(N-1,i+A[i])
            B[low] += 1
            if high+1 < N:
                B[high+1] -= 1
        for i in range(1,N):
            B[i] += B[i-1]
        A = B
    
    print(*A)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    
    if K > 41:
        K = 41
    
    for k in range(K):
        B = [0 for i in range(N)]
        for i in range(N):
            low = max(0,i-A[i])
            high = min(N-1,i+A[i])
            B[low] += 1
            if high+1 < N:
                B[high+1] -= 1
        for i in range(1,N):
            B[i] += B[i-1]
        A = B
    
    print(*A)
    
if __name__ == '__main__':
    main()
X = int(input())
if X >= 2000:
    print(1)
else:
    c = 0
    for i in range(20):
        if X%100 <= i*5:
            c=1
    

print(c)


### FIXED CODE ###

X = int(input())
if X >= 2000:
    print(1)
elif X<= 99:
    print(0)
else:
    c = 0
    for i in range(1,20):
        if int(X//100) == i:
            if X%100 <= i*5:
                c=1
    print(c)
n, k = map(int, input().split())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

P = 10**9 + 7
N = n-k+1
inv_t = [0]+[1]  # 逆元
for i in range(2, N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

A.sort()
mini_count = 0
maxim_count = 0
pattern = 1
"""
minX, maxXとして選ばれるのはそれぞれ
minX:sortAの右からk番目(大きい数値からk個取った時の最小値)とそれより左の要素
maxX:sortAの左からk番目(小さい数値からk個取った時の最大値)とそれより右の要素
選ばれるパターンはminXの場合自分の要素より右にある要素からk-1個を選ぶパターン数
つまり最初は(k-1)C(k-1) = 1
選べる要素が一つ増えるごとに
tC(k-1) ⇒ (t+1)C(k-1)のように増えるので
t * t-1 * t-2 ... * t-k ⇒ t+1 * t * t-1 ... * t-k+1 であり
つまりパターン数は (t+1) / (t-k) 倍になる
"""
for idx in range(k, n + 1):
    mini = A[-idx]  #
    mini_count += mini * pattern % mod
    mini_count %= mod

    maxim = A[idx - 1]
    maxim_count += maxim * pattern % mod
    maxim_count %= mod

    pattern = pattern * (idx) * inv_t[idx + 1 - k] % mod # 割り算のmodは逆元をかける

ans = maxim_count - mini_count
ans %= mod

print(ans)


### FIXED CODE ###

P = 10**9 + 7
N = 1000000
inv_t = [0]+[1]
for i in range(2,N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]



n, k = map(int, input().split())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

A.sort()

mini_count = 0
maxim_count = 0
pattern = 1
for i in range(n-k, -1, -1):
    mini = A[i]
    mini_count += mini * pattern % mod
    mini_count %= mod
    pattern = pattern * (n-i) * inv_t[n-i-k+1] % mod


pattern = 1
for i in range(n-k+1, 0, -1):
    maxim = A[-i]
    maxim_count += maxim * pattern % mod
    maxim_count %= mod
    pattern = pattern * (n-i+1) * inv_t[n-i-k+2] % mod

ans = maxim_count - mini_count
ans %= mod

print(ans)
N = int(input())
# N = random.randint(1,2*10**5)

N_ =str(N)
n_o=len(N_)

# ans:条件を満たす組みの個数
ans=0

def get_ans(A):
    ans=0
    A_=str(A)
    a_s=A_[0]
    a_e=A_[-1]
#     print(a_s,a_e)
    
    if int(a_e) == 0:
        return 0

    if a_s == a_e:
        ans+=1

    for b_o in range(2,n_o+1):
        B_temp = []
        if b_o < n_o:
            ans += 10**(b_o-2)

        elif b_o == n_o:
            if int(a_e) > int(N_[0]):
                break
            elif int(a_e) < int(N_[0]):
                ans += 10 ** (b_o-2)
            else:
                ans+=int(N_[1:-1])

        else:
            break
        
    return ans

for a in range(1,N+1):
    ans_=get_ans(a)
    ans+=ans_
print(ans)

### FIXED CODE ###

N = int(input())

C=[[0]*10 for _ in range(10)]

for n in range(1,N+1):
    n=str(n)
    n_s=int(n[0])
    n_e=int(n[-1])
    
    C[n_s][n_e]+=1
    
ans=0
for c_1 in range(10):
    for c_2 in range(10):
        ans += C[c_1][c_2]*C[c_2][c_1]
        
print(ans)
import sys
input = sys.stdin.readline
import bisect
import numpy as np
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a = np.array(a)
b = np.array(b)
x = max(max(a),max(b)).bit_length()+1
ans = 0
for i in range(1,x+1):
  c = sorted(np.bitwise_and(a,(1<<i)-1))
  d = sorted(np.bitwise_and(b,(1<<i)-1))
  t = 1<<(i-1)
  anstmp = 0
  for j in range(n):
    t1 = np.searchsorted(d,t-c[j])
    t2 = np.searchsorted(d,2*t-c[j])
    t3 = np.searchsorted(d,3*t-c[j])
    t4 = np.searchsorted(d,4*t-c[j])
    anstmp += (t2-t1)+(t4-t3)
  if anstmp%2:
    ans += t
print(ans)

### FIXED CODE ###

a,b,c=map(int,input().split())
if a+b>=c:
  print("Yes")
else:
  print("No")
N, u, v = (int(i) for i in input().split())
adj=[]
for i in range(N+1):adj.append([])
for i in range(N-1):
	a,b = map(int,input().split())
	adj[a]+=[b]
	adj[b]+=[a]
	
prof = [0]*(N+1)
haut = [0]*(N+1)
parent = [-1]*(N+1)

def enraciner(sommet):
	for s in adj[sommet]:
		if s!=parent[sommet]:
			parent[s] = sommet
			# ~ prof[s] = 1+prof[sommet]
			enraciner(s)
	haut[sommet] = 1
	# ~ tmp = [haut[s]for s in adj[sommet] if s!=parent[sommet]]
	# ~ if tmp: haut[sommet]+=max(tmp)

enraciner(v)

# ~ print("parent",parent)
# ~ print("haut",haut)
# ~ print("prof",prof)

ans = 0

#montee
pu = prof[u]
pv = prof[v]
m = (pu - pv -1)//2
pu-=m
pv+=m
# ~ print("m",m)
ans+=m
for i in range(m):
	u = parent[u]

mx = 0
if len(adj[u])>1:mx = max(haut[i] for i in adj[u] if i!= parent[u])
# ~ print("mx",mx)
ans+= mx

last = (pu-pv)//2
# ~ print("last",last)
ans+=last

print(ans)



### FIXED CODE ###

N, u, v = (int(i) for i in input().split())
adj=[]
for i in range(N+1):adj.append([])
for i in range(N-1):
	a,b = map(int,input().split())
	adj[a]+=[b]
	adj[b]+=[a]

def distances(sommet):
	d = [-1]*(N+1)
	File = [sommet]
	d[sommet] = 0
	while File:
		s = File.pop()
		for x in adj[s]:
			if d[x]==-1:
				d[x] = 1+d[s]
				File.append(x)
	return d


t = distances(u)
a = distances(v)

# ~ print(t)
# ~ print(a)

ans = -1
for i in range(1,N+1):
	if t[i]<a[i]:
		ans = max(ans, a[i]-1)
		
print(ans)
import sys


def isprime(n):
    '''check if integer n is a prime'''

    # make sure n is a positive integer
    n = abs(int(n))

    # 0 and 1 are not primes
    if n < 2:
        return False

    # 2 is the only even prime number
    if n == 2: 
        return True    

    # all other even numbers are not primes
    if not n & 1: 
        return False

    # range starts with 3 and only needs to go up 
    # the square root of n for all odd numbers
    for x in range(3, int(n**0.5) + 1, 2):
        if n % x == 0:
            return False

    return True


max = sys.stdin.readline()
answer = []

for x in [0..max-1]:
    n = sys.stdin.readline()
    if isprime(n):
        answer.append(n)

print(' '.join(answer))

### FIXED CODE ###

import sys


def isprime(n):
    '''check if integer n is a prime'''

    # make sure n is a positive integer
    n = abs(int(n))

    # 0 and 1 are not primes
    if n < 2:
        return False

    # 2 is the only even prime number
    if n == 2: 
        return True    

    # all other even numbers are not primes
    if not n & 1: 
        return False

    # range starts with 3 and only needs to go up 
    # the square root of n for all odd numbers
    for x in range(3, int(n**0.5) + 1, 2):
        if n % x == 0:
            return False

    return True


max = int(sys.stdin.readline())
answer = 0

for x in range(max):
    n = sys.stdin.readline()
    if isprime(int(n)):
        answer += 1

print(answer)
inputStr = raw_input().split(' ')
a = int(inputStr[0])
b = int(inputStr[1])
c = int(inputStr[2])
if(a < b && b < c):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

inputStr = input().split(' ')
a = int(inputStr[0])
b = int(inputStr[1])
c = int(inputStr[2])
if a < b & b < c:
  print("Yes")
else:
  print("No")
import fractions
from functools import reduce
 
def lcm_b(a, b):
        #print("base",a,b)
        return (a * b) // fractions.gcd(a, b)
 
def lcm_o():
        global n
        return reduce(lcm_b, n)
 
def chk(v):
        global n
        for i in range(1,30):
                if v%2 == 1:break
                v = v//2
        t=2**(i-1)
        for j in range(len(n)):
                s=n[j]/t
                if n[j] % t == 0 and s % 2 == 1:
                        n[j] = int(s)
 
                else: return 0
        return t/2
 
def mp(v):
        if v%2==1:v+=1
        return int(v//2)
 
N,M= [int(i) for i in input().split()]
n = [int(i) for i in input().split()]
n=sorted(set(n),reverse = True)
bs = int(n[0]*0.5)
 
if len(n) > 1:
        c = chk(n[-1])
        if  c != 0:
                v = lcm_o()*c
                if v > M: print(0) 
 
                else: print(mp(M//v))
        
        else: print(0)
        
elif len(n)==1: print(mp(M//bs))

### FIXED CODE ###

import fractions
from functools import reduce
N,M= [int(i) for i in input().split()]
n = [int(i) for i in input().split()]
#print(n)
n=sorted(set(n),reverse = True)
bs = n[0]
#print(n)
#c=len(n)
 
 
def lcm_b(a, b):
        #print("base",a,b)
        return (a * b) // fractions.gcd(a, b)
 
def lcm_o():
        global n
        return reduce(lcm_b, n)
 
def chk(v):
        global n
        for i in range(1,30):
                if v%2 == 1:break
                v = v//2
        t=2**(i-1)
        for j in range(len(n)):
                if n[j] % t == 0 and (n[j] / t) % 2 == 1:
                        n[j] = int(n[j]/t)
                else: return 0
        return i-1
 
if len(n) > 1:
        
        c = chk(n[-1])
        
        if  c != 0:
                v = lcm_o()*(2**(c-1))
                
                if v > M:
                        print(0) 
                else:
                        v = M//v
                        if v%2==1: v+=1
                        print(int(v//2))
        
        else: print(0)
elif len(n)==1:
        v = int(bs*0.5)
        v = M//v
        if v%2==1: v+=1
        print(int(v//2))
from operator import mul
from functools import reduce

def main ():
  count = int(input())
  c = list(map(int,input().split()))
  print(c)

  if 0 in list:
    print(0)

  a = reduce(mul, list)

  if a > 1000000000000000000:
    print('-1')
  else:
    print(a)

main()

### FIXED CODE ###

def main ():
  count = int(input())
  c = list(map(int,input().split()))

  if 0 in c:
    print(0)
    return

  result = 1
  for a in c:
    result *= a
    if result > 1000000000000000000:
      print(-1)
      return

  print(result)

main()
import numpy as np
n,q= map(int,input().split())

edges = {i+1:[] for i in range(n+1)}
for i in range(n-1):
  a,b = map(int,input().split())
  edges[a].append(b)

ans = np.zeros(n)
dp = {i:np.zeros(n) for i in range(1,n+1)}
for i in range(1,n+1):
  dp[i][i-1] = 1
for i in range(n,0,-1):
  for j in edges[i]:
    dp[i] += dp[j]

queries = [0]*(n+1)
for _ in range(q):
  p,x = map(int,input().split())
  queries[p] += x
for i in range(1,n+1):
  ans += queries[i]*dp[i]
    
st = ""
for i in range(n):
  if i != 0:
    st+=" "
  st+= str(int(ans[i]))
print(st)

### FIXED CODE ###

n = int(input())
s = input()
if n< 3200:
  print("red")
else:
  print(s)
u, l, d, r = map(int, input().split())
mod = 10 ** 9 + 7

def extGCD(a, b):
    if b == 0:
        return a, 1, 0
    g, y, x = extGCD(b, a%b)
    y -= a//b * x
    return g, x, y

def moddiv(a, b):
    _, inv, _ = extGCD(b, mod)
    return (a * inv) % mod

f = [0] * (2 * 10 ** 6 + 2)
f[0] = 1
for i in range(1, 2 * 10 ** 6 + 2):
    f[i] = (f[i-1] * i) % mod

def comb(a, b):
    return moddiv(moddiv(f[a+b], f[a]), f[b])

ans = 0
d += 1
r += 1
ans += comb(d, r)
ans += comb(u, l)
ans -= comb(d, l)
ans -= comb(u, r)
print(ans % mod)

### FIXED CODE ###

u, l, d, r = map(int, input().split())
mod = 10 ** 9 + 7

def extGCD(a, b):
    if b == 0:
        return a, 1, 0
    g, y, x = extGCD(b, a%b)
    y -= a//b * x
    return g, x, y

def moddiv(a, b):
    _, inv, _ = extGCD(b, mod)
    return (a * inv) % mod

f = [0] * (2 * 10 ** 6 + 10)
f[0] = 1
for i in range(1, 2 * 10 ** 6 + 10):
    f[i] = (f[i-1] * i) % mod

def comb(a, b):
    return moddiv(moddiv(f[a+b], f[a]), f[b])

ans = 0
d += 1
r += 1
ans += comb(d, r)
ans += comb(u, l)
ans -= comb(d, l)
ans -= comb(u, r)
print(ans % mod)
from itertools import combinations 
n,k=map(int,input().split())
m = (n-1)*(n-2)//2
if k>m:
    print(-1)
else:
    es = []
    for i in range(2,n+1):
        es.append('1 %d' % i)
        
    idx = 0
    for i,j in combinations(range(2,n+1),2):
        if idx == m-k:
            break
        es.append(f'%d %d' % (i,j))
        idx +=1
    print(len(es))
    print(*es,sep="\n")

### FIXED CODE ###

from itertools import combinations 
n,k=map(int,input().split())
m = (n-1)*(n-2)//2
if k>m:
    print(-1)
else:
    es = []
    for i in range(2,n+1):
        es.append((1,i))
        
    idx = 0
    for i,j in combinations(range(2,n+1),2):
        if idx == m-k:
            break
        es.append((i,j))
        idx +=1
    print(len(es))
    for i,j in es:
        print(i,j)
a,b,c=map(int,input())

if a==b+c or b==a+c or c==a+b:
  print("Yes")
  
else:
  print("No")

### FIXED CODE ###

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

if a==b+c or b==a+c or c==a+b:
  print("Yes")
  
else:
  print("No")
N, x, y = list(map(int, input().split()))
import math
INF = math.inf
adj_mtx = [ [INF] * (N+1) for _ in range(N+1) ]

for i in range(1, N+1):
  if i != N:
    adj_mtx[i][i] = 0
    adj_mtx[i][i+1] = 1
    adj_mtx[i+1][i] = 1
adj_mtx[x][y] = 1
adj_mtx[y][x] = 1

for k in range(1, N+1):
  for i in range(1, N+1):
    for j in range(1, N+1):
      if i == 1 and j == 6 and k == 7: import pdb; pdb.set_trace()
      adj_mtx[i][j] = min(adj_mtx[i][j], adj_mtx[i][k] + adj_mtx[k][j])

for i in range(1, N):
  print(sum([ r.count(i) for r in adj_mtx ]) // 2)

### FIXED CODE ###

N, X, Y = list(map(int, input().split()))
result = [0] * N


for i in range(1, N):
  for j in range(i+1, N+1):
    step = min( j-i, abs(i-X)+1+abs(j-Y), abs(i-Y)+1+abs(j-X))
    result[step] += 1

for e in result[1:]: print(e)
import math
from collections import deque
import copy

def cha(maze,h,w):
    maze = copy.deepcopy(maze)
    for i in range(h):
        for j in range(w):
            if maze[i][j] == ".":
                maze[i][j] = math.inf
            if maze[i][j] == "#":
                maze[i][j] = -1
    return maze

def bfs(maze,sy,sx):
    maze = copy.deepcopy(maze)
    maze[sy][sx] = 0
    que = deque([[sy,sx]])
    while que:
        y,x = que.popleft()
        for next_y,next_x in [(y+1,x),(y-1,x),(y,x+1),(y,x-1)]:
            if maze[next_y][next_x] == -1:
                continue
            dist = maze[next_y][next_x]
            if dist > maze[y][x] + 1:
                maze[next_y][next_x] = maze[y][x] + 1
                que.append([next_y,next_x])
    return maze

def search(maze):
    c = 0
    for i in maze:
        i.append(c)
        c = max(i)
    return c

def _main():
    h,w = map(int,input().split())
    maze = [["#"]*w]
    for _ in range(h):
        maze.append(list(input()))
    maze.append(["#"]*w)
    for i in range(h+2):
        maze[i].insert(0,"#")
        maze[i].insert(w+1,"#")
    C = 0
    for sy in range(h+2):
        for sx in range(w+2):
            if maze[sy][sx] == ".":
                C = max((search(bfs(cha(maze,h+2,w+2),sy,sx)),C))
    print(C)
if __name__=="__main__":
  	_main()

### FIXED CODE ###

from collections import deque
import copy

def cha(maze,h,w):
    maze = copy.deepcopy(maze)
    for i in range(h):
        for j in range(w):
            if maze[i][j] == ".":
                maze[i][j] = 10**10
            if maze[i][j] == "#":
                maze[i][j] = -1
    return maze

def bfs(maze,sy,sx):
    maze = copy.deepcopy(maze)
    maze[sy][sx] = 0
    que = deque([[sy,sx]])
    while que:
        y,x = que.popleft()
        for next_y,next_x in [(y+1,x),(y-1,x),(y,x+1),(y,x-1)]:
            if maze[next_y][next_x] == -1:
                continue
            dist = maze[next_y][next_x]
            if dist > maze[y][x] + 1:
                maze[next_y][next_x] = maze[y][x] + 1
                que.append([next_y,next_x])
    return maze

def search(maze):
    c = 0
    for i in maze:
        i.append(c)
        c = max(i)
    return c

def _main():
    h,w = map(int,input().split())
    maze = [["#"]*w]
    for _ in range(h):
        maze.append(list(input()))
    maze.append(["#"]*w)
    for i in range(h+2):
        maze[i].insert(0,"#")
        maze[i].insert(w+1,"#")
    C = 0
    for sy in range(h+2):
        for sx in range(w+2):
            if maze[sy][sx] == ".":
                C = max((search(bfs(cha(maze,h+2,w+2),sy,sx)),C))
    print(C)

if __name__=="__main__":
    _main()
n = int(input())
a = [int(input()) for i in range(n)]
check = []
cnt = 0
i = 0
while True:
    if i not in check:
        check.append(i)
        i = a[i]-1
    elif cnt >= len(n):
        print(-1)
        break
    if i == 1:
        print(len(check))
        break
    cnt += 1
    
    

### FIXED CODE ###

n = int(input())
a = [None]
for j in range(n):
    a.append(int(input()))

i = 1
c = 0
r = [1]
while True:
    c += 1
    i = a[i]
    if i == 2:
        print(c)
        break
    if c > (10**5):
        print(-1)
        break
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
import numpy as np

N = int(input())

G = np.full((N, N), 10**12)

if N==1:
    print(1)
else:
    for i in range(N-1):
        u, v, w = map(int, input().split())
        G[u-1][v-1] = w
        G[v-1][u-1] = w

    G2 = csgraph_from_dense(G, null_value=10**12)
    d = dijkstra(G2, indices=0)

    for dist in d:
        if dist % 2 == 0:
            print(1)
        else:
            print(0)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)


N = int(input())
G = [[] for i in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    if w % 2 == 0:
        G[u-1].append((v-1, 1))
        G[v-1].append((u-1, 1))
    else:
        G[u-1].append((v-1, -1))
        G[v-1].append((u-1, -1))

color = [None for i in range(N)]


def set_color(v, c):
    color[v] = c
    for next_v, d in G[v]:
        if color[next_v] is None:
            set_color(next_v, d*c)


set_color(0, 1)

for c in color:
    if c == 1:
        print(1)
    else:
        print(0)
s=input()
if s==="AAA" or "BBB":
  print('No')
else:
  print('Yes')
  

### FIXED CODE ###

s=input()
if s=='AAA' or s=='BBB':
  print('No')
else:
  print('Yes')
def binary_search(c1, c2):
    m = (c1 + c2 + 1) // 2
    if abs(c1 - c2) <= 1:
        return m
    else:
        cnt = 0
        for i in a:
            cnt += i // m
        #print(cnt, m)
        if cnt <= k:
            c2 = m
        else:
            c1 = m
        return binary_search(c1, c2)

n, k = map(int, input().split())
a = list(map(int, input().split()))
x = binary_search(-1, 10 ** 9)
for i in range(x + 5, max(x - 5, 0), -1):
    cnt = 0
    for j in a:
        cnt += j // i
    if cnt <= k:
        ans = i
print(ans if not k == 0 else max(a))

### FIXED CODE ###

def binary_search(c1, c2):
    m = (c1 + c2 + 1) // 2
    if abs(c1 - c2) <= 1:
        return m
    else:
        cnt = 0
        for i in a:
            cnt += (i - 1) // m
        #print(cnt, m)
        if cnt <= k:
            c2 = m
        else:
            c1 = m
        return binary_search(c1, c2)

n, k = map(int, input().split())
a = list(map(int, input().split()))
x = binary_search(0, 10 ** 9)
for i in range(x + 5, max(x - 5, 0), -1):
    cnt = 0
    for j in a:
        cnt += (j - 1) // i
    if cnt <= k:
        ans = i
print(ans if not k == 0 else max(a))
dp = [0 for i in range(100)]
dp[6] = 1
dp[3] = 1
for i in range(100):
  if i>=4 and dp[i-4]==1:
    dp[i] = 1
  if i>=7 and dp[i-7]==1:
    dp[i] = 1
if dp(int(input()-1))==1:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

dp = [0 for i in range(100)]
dp[6] = 1
dp[3] = 1
for i in range(100):
  if i>=4 and dp[i-4]==1:
    dp[i] = 1
  if i>=7 and dp[i-7]==1:
    dp[i] = 1
if dp[int(input())-1]==1:
  print("Yes")
else:
  print("No")
N,C = list(map(int,input().split()))
D = [ list(map(int,input().split()))  for i in range(C)]
c = [ list(map(int,input().split()))  for i in range(N)]

sep = {0:[0 for i in range(C)],1:[0 for i in range(C)],2:[0 for i in range(C)]}
for i,cx in enumerate(c):
    for j,cy in enumerate(cx):
        if len(c) == 2 and (i + j) % 3 == 2:
            sep[(i + j) % 3 - 1][cy -1] += 1
        else:
            sep[(i + j) % 3][cy - 1] += 1
minimums = [[],[],[]]
for key,values in sep.tems():
    for i in range(C):
        m0 = 0
        am0 = 0
        m1 = 0
        am1 = 1
        deposit = 0
        for j,value in enumerate(values):
            deposit += D[j][i] * valuea
        sep[key].append(deposit)
min0 = min(sep[0])
min1 = min(sep[1])
min2 = min(sep[2])

print(min1 + min2 + min0)


### FIXED CODE ###

# 基本は３で割ったあまり毎に変換コストを計算する.
# a[i][j] i種類目がj色に変わる時のコストと計算し、それの合計のminを取る

import numpy as np
N,C = map(int,input().split())
a = np.zeros((3,C))
D = np.array([ list(map(int,input().split())) for i in range(C)])
c = np.array([ list(map(int,input().split())) for i in range(N)])


for i in range(N):
    for j in range(N):
        a[(i+j)%3] += D[c[i][j]-1]

sum_arr = []
for C1 in range(C):
    for C2 in range(C):
        for C3 in range(C):
            if C1 != C2 and C2 != C3 and C3 != C1:
                sum_arr.append(a[0][C1]+a[1][C2]+a[2][C3])

print(int(min(sum_arr)))
a = list(input())
b = list(input())
c = list(input())
x = "d"
a_idx = 0
b_idx = 0
c_idx = 0
while a_idx != len(a) -1 and b_idx != len(b) -1 and c_idx != len(c) -1:
    if x == "a":
        x = str(a[a_idx])
        a_idx += 1
    elif x == "b":
        x = str(b[b_idx])
        b_odx += 1
    elif x == "c":
        x = str(c[c_idx])
        c_idx += 1
    else:
        x = "a"
if a_idx == len(a) -1 :
    print("A")
elif b_idx == len(b)-1:
    print("B")
else:
    print("C")

### FIXED CODE ###

s=[input() for i in range(3)]
l=[len(s[i]) for i in range(3)]
abc=[0,0,0]
now=0
while abc[now]!=l[now]:
    s_sub=s[now][abc[now]]
    abc[now]+=1
    now=(0 if s_sub=="a" else 1 if s_sub=="b" else 2)
print("A" if now==0 else "B" if now==1 else "C")