Harryxun/stf_run huggingface dataset:
A=[]
for i in range(3):
    A.append(list(input().split()))
N=int(input())
B=list(input() for i in range(N))

for i in range (N):
    for j in range(len(A[0])):
        if (B[i] in A[j]):
            #print(type(B[i]),B[i],A[j])
            A[j][A[j].index(B[i])]=0
check=0
if((A[0][0]+A[1][1]+A[2][2]==0) or (A[2][0]+A[1][1]+A[0][2]==0) ):
    print('Yes');check=1
else:    
    for j in range(len(A[0])): 
        if( (A[j][0]+A[j][1]+A[j][2]==0) or (A[0][j]+A[1][j]+A[2][j]==0)    ):    
            print('Yes');check=1
            break;
    if(check==0):
        print('No')

### FIXED CODE ###

A=[]
for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
B=list(int(input()) for i in range(N))

for i in range(N):
    for j in range(3):
        for k in range(3):
            if B[i] == A[j][k]:
                A[j][k] = 0             
if( ((A[0][0]==0) and (A[1][1]==0) and (A[2][2]==0)) or
   ((A[2][0]==0) and (A[1][1]==0) and (A[0][2]==0)) ):
    print('Yes');exit(0)


for j in range(len(A[0])): 
    if( ((A[j][0]==0) and (A[j][1]==0) and (A[j][2]==0)) or
       ((A[0][j]==0) and (A[1][j]==0) and (A[2][j]==0))    ):    
        print('Yes');
        exit(0)

print('No')
n = int(input())
edges = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)
f = 0
s = 0
from collections import deque
ps = [-1] * n
used = [False] * n
used[0] = True # 始めどこから行くか
q = deque([0])
while len(q) > 0:
    a = q.popleft()
    if a == n-1:
        break
    for u in edges[a]:
        if not used[u]:
            ps[u] = a
            q.append(u)
            used[u] = True
nx = n - 1
xs = [n-1]
while nx != 0:
    nx = ps[nx]
    xs.append(nx)
l = len(xs) - 2
f = (l + 1)//2
s = l - f

mid = len(xs)//2

# bfs 0側
used = [-1] * n
used[0] = 0 
q = deque([0])
cnt = 0
while len(q) > 0:
    a = q.popleft()
    for u in edges[a]:
        if used[u] == -1 and u != xs[mid+1]:
            q.append(u)
            used[u] = 0
            cnt += 1
# print("cnt",cnt)
f += cnt

# bfs n-1側
used = [-1] * n
used[n-1] = 0 
q = deque([n-1])
cnt = 0
while len(q) > 0:
    a = q.popleft()
    for u in edges[a]:
        if used[u] == -1 and u != xs[mid]:
            q.append(u)
            used[u] = 0
            cnt += 1
# print("cnt",cnt)
s += cnt

if f > s:
    print("Fennec")
else:
    print("Snuke")


### FIXED CODE ###

n = int(input())
edges = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)
f = 0
s = 0
from collections import deque
ps = [-1] * n
used = [False] * n
used[0] = True # 始めどこから行くか
q = deque([0])
while len(q) > 0:
    a = q.popleft()
    if a == n-1:
        break
    for u in edges[a]:
        if not used[u]:
            ps[u] = a
            q.append(u)
            used[u] = True

nx = n - 1
xs = [n-1]
while nx != 0:
    nx = ps[nx]
    xs.append(nx)

xs.reverse()
l = len(xs) - 2
f = (l+1)//2
s = l-f

if len(xs) == 2:
    z_lim = -1
    n_lim = 0
else:
    z_lim = (len(xs)+1)//2
    n_lim = z_lim - 1

# bfs 0側
used = [-1] * n
used[0] = 0 
q = deque([0])
cnt = 0
while len(q) > 0:
    a = q.popleft()
    for u in edges[a]:
        if used[u] == -1 and u != xs[z_lim]:
            q.append(u)
            used[u] = 0
            cnt += 1
# print("cnt",cnt)
f += cnt

# bfs n-1側
used = [-1] * n
used[n-1] = 0 
q = deque([n-1])
cnt = 0
while len(q) > 0:
    a = q.popleft()
    for u in edges[a]:
        if used[u] == -1 and u != xs[n_lim]:
            q.append(u)
            used[u] = 0
            cnt += 1

s += cnt
# print("z_lim",z_lim,"nlim",n_lim)
# print("f",f,"s",s)
if f > s:
    print("Fennec")
else:
    print("Snuke")
import sys
#from collections import deque
#from functools import *
#from fractions import Fraction as f
from copy import *
from bisect import *	
#from heapq import *
#from math import ceil
#from itertools import permutations ,product
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=0
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
di=[[-1,0],[1,0],[0,1],[0,-1]]
def inc(d,c,x=1):
	d[c]=d[c]+x if c in d else x
def bo(i):
	return ord(i)-ord('A')	
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0		
def gi():	
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a): 
	return reduce(lambda a,b:a*b,a)		
def swap(a,i,j): 
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())			
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<m and a[i][j]!="."
def bo(i):
	return ord(i)-ord('a')	
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)
def represent(n):
	s=""
	while n>0:
		s+=str(n%3)
		n//=3
	s=s[::-1]
	return s			

t=1
while t>0:
	t-=1
	a,b,c,d=mi()
	print(b*d)					





### FIXED CODE ###

import sys
#from collections import deque
#from functools import *
#from fractions import Fraction as f
from copy import *
from bisect import *	
#from heapq import *
#from math import ceil
#from itertools import permutations ,product
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
di=[[-1,0],[1,0],[0,1],[0,-1]]
def inc(d,c,x=1):
	d[c]=d[c]+x if c in d else x
def bo(i):
	return ord(i)-ord('A')	
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0		
def gi():	
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a): 
	return reduce(lambda a,b:a*b,a)		
def swap(a,i,j): 
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())			
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<m and a[i][j]!="."
def bo(i):
	return ord(i)-ord('a')	
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)
def represent(n):
	s=""
	while n>0:
		s+=str(n%3)
		n//=3
	s=s[::-1]
	return s			

t=1
while t>0:
	t-=1
	a,b,c,d=mi()
	maxi=-10**19
	for i in a,b:
		for j in c,d:
			maxi=max(maxi,i*j)		
	print(maxi)
K,X=map(int,input().split())
print(*list[X-K+1:X+K])

### FIXED CODE ###

K,X=map(int,input().split())
print(*list(range(X-K+1,X+K)))
ab = input().split();

a = ab[0]
b = ab[1]
 
if a >= 13:
  print(b)
elif a >= 6:
  print((int)b/2)
else:
  print(0)

### FIXED CODE ###

a,b = map(int, input().split())
 
ans=0
if a <= 5:
	ans = 0
elif a >= 6 and a<=12:
	ans = b/2
else:
	ans = b
 
print(int(ans))
list(nyu = input())

for i in nyu:
    if i == "1":
        print("9", end="")
    elif  i == "9":
        print("1", end="")
print()


### FIXED CODE ###

nyu = input()
list(nyu)

for i in nyu:
    if i == "1":
        print("9", end="")
    elif  i == "9":
        print("1", end="")
print()
h,w=map(int,input().split())
a=[]

for i in range(h):
  x=list(map(int,input().split()))
  a.append(x)
ans=[]
times=0
for i in range(h):
  for j in range(w-1):
    if a[i][j]%2!=0:
      a[i][j]-=1
      a[i][j+1]+=1
      ans.append([i+1,j+1,i+1,j+2])
      times+=1
for i in range(h-1):
  if a[i][w-1]%2!=0:
    a[i][w-1]-=1
    a[i+1][w-1]+=1
    ans.append([i+1,w,i+2,w])
    times+=1
print(times)
for i in range(len(ans)):
  print(ans[i])

### FIXED CODE ###

a,b,=map(int,input().split())
if a%2!=0 and b%2!=0:
  print('Yes')
else:
  print('No')
icase=0
if icase==0:
    w,h=map(int,input().split())
#    xy=[[1]*w for i in range(2*h)]
    for i in range(h):
        cij=input()
        print(cij)
        print(cij)
        

### FIXED CODE ###

icase=0
if icase==0:
    h,w=map(int,input().split())
#    xy=[[1]*w for i in range(2*h)]
    for i in range(h):
        cij=input()
        print(cij)
        print(cij)
n = int(input())

ans = 0

def calc(b,e):
    cnt = e // b
    return (b + e) * cnt // 2

for i in range(1, n+1):
    ans += calc(i, n//i * i)
    print(ans)

print(ans)

### FIXED CODE ###


n = int(input())

ans = 0

def calc(b,e):
    cnt = e // b
    return (b + e) * cnt // 2

for i in range(1, n+1):
    ans += calc(i, n//i * i)

print(ans)
sum_ = sum(s)
    if (sum_ % 10) != 0:
        return sum_
    else:
        st = sorted(s)
        m = 0
        for i in range(len(st)):
            s2 = sum(s[:i-1]+s[i+1:])
            if (s2 % 10) != 0:
                return s2

        for i in range(len(st)):
            s2 = sum(s[:i-1]+s[i+2:])
            if (s2 % 10) != 0:
                return s2
    return 0

N = int(input())
a = [int(input()) for i in range(N)]
print(max_of(a)) # [a1, a2, a3, ..., aN]



### FIXED CODE ###

import sys

def gen_list(lst):
    length = len(lst)
    dp = [{}] * length
    dp[0] = {lst[0]: True}
    dp[0][0] = True

    # s[i]までで出る数字
    for i in range(1, length):
        s = lst[i]
        dp[i] = dp[i-1]
        keys = [k for k in dp[i].keys()]
        for val in keys:
            dp[i][val + s] = True
    
    return sorted(dp[length-1].keys(), reverse=True)

N = int(input())
s = [int(input()) for _ in range(N)]

for m in gen_list(s):
    if m % 10 != 0:
        print(m)
        sys.exit()

print('0')
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def c(n, k):
    from math import factorial

    ans = factorial(n) / factorial(k) / factorial(n - k)

    return ans % mod


mod = 10**9 + 7

x, y = map(int, read().split())

if y > x:
    temp = y
    y = x
    x = temp

if ((x + y) % 3 != 0) or x > y * 2:
    print("0")
else:
    n = ((x + y) // 3)
    k = ((n - abs(x - y)) // 2)
    ans = c(n, k)
    print(ans)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7


def combination(n: int, r: int, mod=MOD):
    n1 = n+1
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


x, y = map(int, read().split())

if ((x + y) % 3 != 0):
    print("0")
else:
    a = (2*y - x) // 3
    b = (x - a) // 2

    if a < 0 or b < 0:
        print(0)
    else:
        print(combination(a+b, a))
import collections

n=int(input())
arr=[int(input()) for _ in range(n)]
arr=sorted(arr)
q=collections.deque()
q.append(arr[0])
l=0
r=0
flag1=0
flag2=0
if len(arr)%2==1:
  while 1:
    if flag1==0:
      r+=1
      if flag2==0:
        q.append(arr[-r])
        flag2=1
      else:
        q.appendleft(arr[-r])
        flag2=0
        flag1=1
    else:
      l+=1
      if flag2==0:
        q.append(arr[l])
        flag2=1
      else:
        q.appendleft(arr[l])
        flag2=0
        flag1=0
    if l+r+1==n:
      break
  q=list(q)
  ans=0
  for i in range(len(q)-1):
    ans+=abs(q[i]-q[i+1])
  print(ans)
else:
  while 1:
    if flag1==0:
      r+=1
      if flag2==0:
        q.append(arr[-r])
        flag2=1
      else:
        q.appendleft(arr[-r])
        flag2=0
        flag1=1
    else:
      l+=1
      if flag2==0:
        q.append(arr[l])
        flag2=1
      else:
        q.appendleft(arr[l])
        flag2=0
        flag1=0
    if l+r+2==n:
      q=list(q)
      lnum=q[0]
      rnum=q[-1]
      if flag1==0:
        r+=1
        if abs(lnum-arr[-r])>abs(rnum-arr[-r]):
          q=[arr[-r]]+q
        else:
          q=q+[arr[-r]]
      else:
        l+=1
        if abs(lnum-arr[l])>abs(rnum-arr[l]):
          q=[arr[l]]+q
        else:
          q=q+[arr[l]]
      break
  q=list(q)
  ans=0
  for i in range(len(q)-1):
    ans+=abs(q[i]-q[i+1])
  print(ans)

### FIXED CODE ###

import collections

n=int(input())
arr=[int(input()) for _ in range(n)]
arr=sorted(arr)
if n%2==1:
  q=collections.deque()
  q.append(arr[0])
  l=1
  r=n-1
  move=1
  while 1:
    q.appendleft(arr[r])
    r-=1
    q.append(arr[r])
    r-=1
    move+=2
    if move==n:
      break
    q.appendleft(arr[l])
    l+=1
    q.append(arr[l])
    l+=1
    move+=2
    if move==n:
      break
  q=list(q)
  ans1=0
  for i in range(n-1):
    ans1+=abs(q[i+1]-q[i])
  q=collections.deque()
  q.append(arr[-1])
  l=0
  r=n-2
  move=1
  while 1:
    q.appendleft(arr[l])
    l+=1
    q.append(arr[l])
    l+=1
    move+=2
    if move==n:
      break
    q.appendleft(arr[r])
    r-=1
    q.append(arr[r])
    r-=1
    move+=2
    if move==n:
      break
  q=list(q)
  ans2=0
  for i in range(n-1):
    ans2+=abs(q[i+1]-q[i])
  ans=max(ans1,ans2)
  print(ans)
else:
  q=collections.deque()
  q.append(arr[0])
  l=1
  r=n-1
  move=1
  while 1:
    if n-move==1:
      break
    q.appendleft(arr[r])
    r-=1
    q.append(arr[r])
    r-=1
    move+=2
    if n-move==1:
      break
    q.appendleft(arr[l])
    l+=1
    q.append(arr[l])
    l+=1
    move+=2
  q=list(q)
  ans1=0
  for i in range(n-2):
    ans1+=abs(q[i+1]-q[i])
  ans1+=max(abs(arr[l]-q[0]),abs(arr[l]-q[-1]))
  q=collections.deque()
  q.append(arr[-1])
  l=0
  r=n-2
  move=1
  while 1:
    if n-move==1:
      break
    q.appendleft(arr[l])
    l+=1
    q.append(arr[l])
    l+=1
    move+=2
    if n-move==1:
      break
    q.appendleft(arr[r])
    r-=1
    q.append(arr[r])
    r-=1
    move+=2
  q=list(q)
  ans2=0
  for i in range(n-2):
    ans2+=abs(q[i+1]-q[i])
  ans2+=max(abs(arr[r]-q[0]),abs(arr[r]-q[-1]))
  ans=max(ans1,ans2)
  print(ans)
a,b,c,d=map(int,input().split())
print(min(a,b)+min(c,d))

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(int(min(a,b)+min(c,d)))
n=input()
if len(n)==1:print(n)
elif n="9"*len(n):print(9*len(n))
else:print(9*(len(n)-1)+int(n[0])-1)

### FIXED CODE ###

n=input()
if len(n)==1:print(n)
elif n=="9"*len(n):print(9*len(n))
elif n[1:]=="9"*(len(n)-1):print(int(n[0])+9*(len(n)-1))
else:print(9*(len(n)-1)+int(n[0])-1)
import sys
import numpy as np
input = sys.stdin.readline

N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]
H = np.array(H, dtype=np.int64)


def C(X):
    """
    x回爆発して、全部消滅させれるとTrue
    """
    HP = np.copy(H)
    HP -= B * X
    HP[HP <= 0] = 0
    cnt = ((HP + A - B - 1) // (A - B)).sum()
    return cnt <= X


l = 0
r = 10 ** 18
while r - l > 1:
    m = (r + l) // 2
    if C(m):
        r = m
    else:
        l = m

ans = r
print(ans)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, A, B = map(int, readline().split())
H = [int(readline()) for _ in range(N)]


def C(T):
    """
    T回爆発させて、魔物全滅できるか
    """
    damage = B * T
    cnt = 0
    for h in H:
        h -= damage
        if h <= 0:
            continue
        cnt += (h + (A - B) - 1) // (A - B)
    return cnt <= T


left = 0
right = 10 ** 18
while right - left > 1:
    mid = (right + left) // 2
    if C(mid):
        right = mid
    else:
        left = mid

ans = right
print(ans)
start = time.time()
A,B,C = map(int,input().split())
flag = 0
if A == 1:
    flag = 1
else:    
    while flag == 0:
        if A%B == C:
            flag = 1
            break
        else:
            A += A
        now = time.time() - start
        if now > 1.9:
            break
if flag == 0:
    print("NO")
else:
    print("YES")

### FIXED CODE ###

A,B,C = map(int,input().split())
tmpA = A
tmp = []
while A%B != C and A%B not in tmp:
    tmp.append(A%B)
    A += tmpA
if A%B == C:
    print("YES")
else:
    print("NO")
(a, b, c) = [int(i) for i in input().split()]
cnt = 0
for i in range(a, b + 1):
    if (c % 1) == 0:
        cnt = cnt + 1
print(cnt)

### FIXED CODE ###

while True:
    (x, y) = [int(i) for i in input().split()]

    if x == 0 and y == 0:
        break
    if x >= y:
        print(y, x)
    else:
        print(x, y)
N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(N)]

sCount = {}
for s in S:
    sCount[s] = S.count(s)

tCount = {}
for t in T:
    tCount[t] = T.count(t)

union = sCount.keys() & tCount.keys()
ans = sCount;
for i in union:
    ans[i] = sCount[i] - tCount[i]
    
print(max(ans.values()))

### FIXED CODE ###

N = int(input())
S = [input() for i in range(N)]
M = int(input())
T = [input() for i in range(M)]

sCount = {}
for s in S:
    sCount[s] = S.count(s)

tCount = {}
for t in T:
    tCount[t] = T.count(t)

union = sCount.keys() & tCount.keys()
ans = sCount;
for i in union:
    ans[i] = sCount[i] - tCount[i]
    
if max(ans.values()) >= 0:
    print(max(ans.values()))
else:
    print(0)
from collections import deque
from copy import copy

r, c = map(int, input().strip().split())
maze = [["#"] * (c + 2)] + [["#"] + list(input().strip()) + ["#"] for _ in range(r)] + [["#"] * (c + 2)]

queue = deque([(i, j) for j in range(1, r + 1) for i in range(1, c + 1) if maze[i][j] == "#"])

def BFS(maze, queue):
    depth = 0
    nextqueue = deque()

    while queue:
        depth += 1
        while queue:
            posr, posc = queue.popleft()
            for r, c in zip([1, -1, 0, 0], [0, 0, 1, -1]):
                nextr = posr + r
                nextc = posc + c
                terrein = maze[nextr][nextc]
                if terrein == ".":
                    maze[nextr][nextc] = "#"
                    nextqueue.append((nextr, nextc))
        queue = copy(nextqueue)
        nextqueue.clear()

    return depth - 1

print(BFS(maze, queue))


### FIXED CODE ###

from collections import deque
from copy import copy

row, column = map(int, input().split())
map_ = [[c == "#" for c in input().strip()] for _ in range(row)]

queue = deque([(i, j) for j in range(column) for i in range(row) if map_[i][j]])

def bfs(maze, queue):
    depth = 0
    while True:
        depth += 1
        nextqueue = deque()
        while queue:
            posr, posc = queue.popleft()
            for dr, dc in zip([1, -1, 0, 0], [0, 0, 1, -1]):
                nextr = posr + dr
                nextc = posc + dc
                if 0 <= nextr < row and 0 <= nextc < column and not maze[nextr][nextc]:
                    maze[nextr][nextc] = True
                    nextqueue.append((nextr, nextc))
        if nextqueue:
            queue = copy(nextqueue)
        else:
            return depth - 1

print(bfs(map_, queue))
h,w,m=map(int,input().split())
bomb=[]
x=[0]*(h+1)
y=[0]*(w+1)
for i in range(m):
    h1,w1=map(int,input().split())
    x[h1]+=1
    y[w1]+=1
    bomb.append((h1,w1))
maxx=max(x)
maxy=max(y)
r=[]
c=[]
for i in range(1,h+1):
    if x[i]==maxx:
        r.append(i)
for j in range(1,w+1):
    if y[i]==maxy:
        c.append(i)
for j in r:
    for k in c:
        if (j,k) not in bomb:
            print(maxx+maxy)
            exit()
print(maxx+maxy-1)

### FIXED CODE ###

h,w,m=map(int,input().split())
bomb=[]
x=[0]*(h+1)
y=[0]*(w+1)
for i in range(m):
    h1,w1=map(int,input().split())
    x[h1]+=1
    y[w1]+=1
    bomb.append((h1,w1))
maxx=max(x)
maxy=max(y)
r=[]
c=[]
bomb=set(bomb)
for i in range(1,h+1):
    if x[i]==maxx:
        r.append(i)
for j in range(1,w+1):
    if y[j]==maxy:
        c.append(j)
for j in r:
    for k in c:
        if (j,k) not in bomb:
            print(maxx+maxy)
            exit()
print(maxx+maxy-1)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

var = raw_input().split(" ")
rect = var[0] * var[1]
length = var[0] * 2 + var[1] * 2

print rect + " " + length

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

var = raw_input().split()
rect = int(var[0]) * int(var[1])
length = int(var[0]) * 2 + int(var[1]) * 2

print str(rect) + " " + str(length)
x = int(input())
for a in range(-200,201):
	for b in range(-200,201):
    	if a**5 - b**5 == x:
        	print(a,b,sep= ' ')
          	exit()

### FIXED CODE ###

S = input()
if S == 'ABC':
  print('ARC')
else:
  print('ABC')
A = input()
B = input()
C = input()

xa = 0
xb = 0
xc = 0

#配列の次のカードの文字を返す
def next(X, i):
    if X[i] == 'a':
        return A[xa]
    elif X[i] == 'b':
        return B[xb]
    else:
        return C[xc]

h = 'A'
xa += 1
k = next(A, xa - 1) #最初

while xa <= len(A) and xb <= len(B) and xc <= len(C):
    if k == 'a':
        h = 'A'
        xa += 1
        k = next(A, xa - 1)
    elif k == 'b':
        h = 'B'
        xb += 1
        k = next(B, xb - 1)
    else:
        h = 'C'
        xc += 1
        k = next(C, xc - 1)

print(h)


### FIXED CODE ###

A = input()
B = input()
C = input()

xa = 0
xb = 0
xc = 0

h = 'A'
k = A[0] #最初の１枚を抜く
xa += 1

while True:

    if k == 'a':
        h = 'A'
        if xa < len(A):
            k = A[xa]
            xa += 1
        else:
            break
    elif k == 'b':
        h = 'B'
        xb += 1
        if xb < len(B):
            k = B[xb]
            xb += 1
        else:
            break
    elif k == 'c':
        h = 'C'
        xc += 1
        if xc < len(C):
            k = C[xc]
            xc += 1
        else:
            break

print(h)
import itertools

L, R = map(int, input().split())
comb = itertools.combinations(range(L, R + 1), 2)
result = float('inf')
for a, b in comb:
    mod = a * b % 2019
    if mod == 0:
        result = 0
        break
    elif mod < result:
        result = mod
print(result)

### FIXED CODE ###

L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
else:
    result = float('inf')
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            mod = (i * j) % 2019
            if mod == 0:
                result = 0
                break
            elif mod < result:
                result = mod
    print(result)
import math

N = int(input())
tr = []

for i in range(5):
  tr.append(int(input())

print(math.ceil(N/min(tr)))


### FIXED CODE ###

import math

N = int(input())
tr = []

for i in range(5):
  tr.append(int(input()))
            
print(math.ceil(N / min(tr))+4)
n,k = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,k):
  if n == 0:
    if k == 0:
      return 0
    else:
      return 1
  if k == 0:
    return 0
  elif k <= a[n-1]+1:
    return f(n-1,k-1)
  elif k == a[n-1]+2:
    return p[n-1]+1
  elif k <= a[n]*2+3:
    return p[n-1]+1+f(n-1,k-2-a[n-1])
print(f(n,k))



### FIXED CODE ###

n,k = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def f(n,k):
  if n == 0:
    if k == 0:
      return 0
    else:
      return 1
  if k == 0:
    return 0
  elif k <= a[n-1]+1:
    return f(n-1,k-1)
  else:
    return p[n-1]+1+f(n-1,k-2-a[n-1])
print(f(n,k))
import math

Num,HP = (map(int,input().split()))
Katanas = [list(map(int,input().split())) for x in range(Num)]

amax = max([x[0] for x in Katanas])
bpower = sorted([x[1] for x in Katanas if x[1] > amax],reverse=True)
attake=0
while HP > 0:
    attake += 1
    HP -= bpower[0]
    if len(bpower) == 1:
        break
    bpower = bpower[1:]
attake += math.ceil(HP/amax) if HP > 0 else 0
print(attake)

### FIXED CODE ###

import math

Num,HP = (map(int,input().split()))
#Katanas = [list(map(int,input().split())) for _ in range(Num)]

CKatanaMax = 0
katanas = []

for _ in range(Num):
    a,b = map(int,input().split())
    CKatanaMax = max(CKatanaMax,a)
    katanas.append(b)

Tkatanas = sorted([x for x in katanas if x > CKatanaMax],reverse=True)

attake = 0
for Tkatana in Tkatanas:
    HP -= Tkatana
    attake += 1
    if HP <= 0:
        break
else:
    attake += math.ceil(HP/CKatanaMax)
print(attake)
a = int(input())
b = input()
c = input()
d = input()
e = int(input()
k = input()
if e - a <= k:
    print("Yay!")
else:
    print(":(")


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e - a <= k:
    print("Yay!")
else:
    print(":(")