Problem:
 Score : 200 points    Problem Statement We have a bingo card with a 3\times3 grid. The square at the i -th row from the top and the j -th column from the left contains the number A_{i, j} .  The MC will choose N numbers, b_1, b_2, \cdots, b_N . If our bingo sheet contains some of those numbers, we will mark them on our sheet.  Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.      Constraints  All values in input are integers.  1 \leq A_{i, j} \leq 100  A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))  1 \leq N \leq 10  1 \leq b_i \leq 100  b_i \neq b_j (i \neq j)         Input Input is given from Standard Input in the following format:  A_{1, 1}  A_{1, 2}  A_{1, 3}  A_{2, 1}  A_{2, 2}  A_{2, 3}  A_{3, 1}  A_{3, 2}  A_{3, 3}  N  b_1  \vdots  b_N       Output If we will have a bingo, print Yes ; otherwise, print No .        Sample Input 1 84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30      Sample Output 1 Yes  We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3} , and complete the diagonal from the top-left to the bottom-right.       Sample Input 2 41 7 46
26 89 2
78 92 8
5
6
45
16
57
17      Sample Output 2 No  We will mark nothing.       Sample Input 3 60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34      Sample Output 3 Yes  We will mark all the squares.

Solution (Python):
a = [list(map(int, input().split())) for i in range(3)]

n = int(input())

k = [int(input()) for p in range(n)]
for s in range(3):
    if a[s][0] in k and a[s][1] in k and a[s][2] in k:
        print("Yes")
        exit()

for t in range(3):
    if a[0][t] in k and a[1][t] in k and a[2][t] in k:
        print("Yes")
        exit()

if a[0][0] in k and a[1][1] in k and a[2][2] in k:
    print("Yes")
    exit()

if a[0][2] in k and a[1][1] in k and a[2][0] in k:
    print("Yes")
    exit()

print("No")

Solution (Python):
a0,a1,a2=map(int,input().split())
a3,a4,a5=map(int,input().split())
a6,a7,a8=map(int,input().split())
N=int(input())
b=[int(input()) for i in range(N)]

s=range(9)
lists=[]
lists.append(a0)
lists.append(a1)
lists.append(a2)
lists.append(a3)
lists.append(a4)
lists.append(a5)
lists.append(a6)
lists.append(a7)
lists.append(a8)

listb=[]
for j in range(N):
  listb.append(b[j])
t=0
for il in range(9):
  for ib in range(N):
    if b[ib]==lists[il]:
      lists[il]=0
            
if lists[0]==lists[1] and lists[2]==lists[1] and lists[0]==0:
  print ('Yes')
elif lists[3]==lists[4] and lists[5]==lists[4] and lists[3]==0:
  print ('Yes')
elif lists[6]==lists[7] and lists[8]==lists[7] and lists[6]==0:
  print ('Yes')
elif lists[0]==lists[3] and lists[3]==lists[6] and lists[0]==0:
  print ('Yes')
elif lists[1]==lists[4] and lists[4]==lists[7] and lists[1]==0:
  print ('Yes')
elif lists[2]==lists[5] and lists[5]==lists[8] and lists[2]==0:
  print ('Yes')
elif lists[0]==lists[4] and lists[4]==lists[8] and lists[0]==0:
  print ('Yes')
elif lists[2]==lists[4] and lists[4]==lists[6] and lists[2]==0:
  print ('Yes')
else:
  print ('No')

Solution (Python):
bingo = [[int(j) for j in input().split()] for i in range(3)]
N = int(input())
for k in range(N):
  flag = 0
  hole = int(input())
  for i in range(3):
    for j in range(3):
      if bingo[i][j] == hole:
        bingo[i][j] = -1
        flag = 1
        break
    if flag == 1:
      break
        
if bingo[0][0] * bingo[0][1] * bingo[0][2] == -1:
  print("Yes")
elif bingo[1][0] * bingo[1][1] * bingo[1][2] == -1:
  print("Yes")
elif bingo[2][0] * bingo[2][1] * bingo[2][2] == -1:
  print("Yes")
elif bingo[0][0] * bingo[1][0] * bingo[2][0] == -1:
  print("Yes")
elif bingo[0][1] * bingo[1][1] * bingo[2][1] == -1:
  print("Yes")
elif bingo[0][2] * bingo[1][2] * bingo[2][2] == -1:
  print("Yes")
elif bingo[0][0] * bingo[1][1] * bingo[2][2] == -1:
  print("Yes")
elif bingo[0][2] * bingo[1][1] * bingo[2][0] == -1:
  print("Yes")
else:
  print("No")

Solution (Python):
A = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
bingo = False
def bingo_check(A,b):
	for i in range(3):
		for j in range(3):
			if A[i][j] == b:
				A[i][j] = -1
	return A

for i in range(n):
	s = int(input())
	A = bingo_check(A,s)

s,t = 0,0
for i in range(3):
	s += A[i][i]
	t += A[i][2-i]
if s == -3 or t == -3:
	bingo = True
if not bingo:
	for i in range(3):
		u,p = 0,0
		for j in range(3):
			u += A[i][j]
			p += A[j][i]
		if u == -3 or p == -3:
			bingo = True
if bingo:
	print('Yes')
else:
	print('No')

Solution (Python):
n11, n12, n13 = map(int,input().split())
n21, n22, n23 = map(int,input().split())
n31, n32, n33 = map(int,input().split())
lines = [[n11,n12,n13],
         [n21,n22,n23],
         [n31,n32,n33],
         [n11,n21,n31],
         [n12,n22,n32],
         [n13,n23,n33],
         [n11,n22,n33],
         [n13,n22,n31]]
nums = {}
r = input()
for i in range(int(r)):
  nums[int(input())] = 0
flag = False
for l in lines:
  if l[0] in nums:
    if l[1] in nums:
      if l[2] in nums:
        flag = True
if flag:
  print("Yes")
else:
  print("No")

Solution (Python):
a1,a2,a3 = input().split()
a4,a5,a6 = input().split()
a7,a8,a9 = input().split()
alist = [a1,a2,a3,a4,a5,a6,a7,a8,a9]
N = int(input())
for i in range(N):
  b = input()
  acnt = 0
  for a in alist:
    if a==b:
      alist[acnt] = -1
      break
    acnt += 1 
if (alist[0]==alist[4]==alist[8]
    or alist[2]==alist[4]==alist[6]
    or alist[0]==alist[1]==alist[2]
    or alist[3]==alist[4]==alist[5]
    or alist[6]==alist[7]==alist[8]
    or alist[0]==alist[3]==alist[6]
    or alist[1]==alist[4]==alist[7]
    or alist[2]==alist[5]==alist[8]):
  print('Yes')
else:
  print('No')

Solution (Python):
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
_A = [[0, 0, 0] for _ in range(3)]
for i in range(N):
    num = int(input())
    for j in range(3):
        if num in A[j]:
            idx = A[j].index(num)
            _A[j][idx] = 1
if sum(_A[0]) == 3 or sum(_A[1]) == 3 or sum(_A[2]) == 3:
    print('Yes')
elif sum([a[0] for a in _A]) == 3 or sum([a[1] for a in _A]) == 3 or sum([a[2] for a in _A]) == 3:
    print('Yes')
elif _A[0][0] + _A[1][1] + _A[2][2] == 3 or _A[0][2] + _A[1][1] + _A[2][0] == 3:
    print('Yes')
else:
    print('No')

Solution (Python):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())

A = A1 + A2 + A3

while(N != 0):
    b = int(input())
    if b in A:
        A[A.index(b)] = 0
    N = N - 1

while(N != 0):
    b = int(input())
    if b in A:
        A[A.index(b)] = 0
    N = N - 1

if(A[0:3] == [0,0,0] or A[3:6] == [0,0,0] or A[6:9] == [0,0,0]):
    print('Yes')
    
elif(A[0::3] == [0,0,0] or A[1::3] == [0,0,0] or A[2::3] == [0,0,0]):
    print('Yes')

elif(A[0] + A[4] + A[8] == 0 or A[2] + A[4] + A[6] ==0):
    print('Yes')
    
else:
    print('No')

Solution (Python):
bingo = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
l = [int(input()) for _ in range(n)]
for i in range(3):
    if bingo[i][0] in l and bingo[i][1] in l and bingo[i][2] in l:
        print("Yes")
        exit()
for i in range(3):
    if bingo[0][i] in l and bingo[1][i] in l and bingo[2][i] in l:
        print("Yes")
        exit()
if bingo[0][0] in l and bingo[1][1] in l and bingo[2][2] in l:
    print("Yes")
    exit()
if bingo[0][2] in l and bingo[1][1] in l and bingo[2][0] in l:
    print("Yes")
    exit()
print("No")

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = list(int(input()) for _ 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
                break

for i in range(3):
    if a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0:
        print("Yes")
        break
    elif a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0:
        print("Yes")
        break
else:
    if a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0:
        print("Yes")
    elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0:
        print("Yes")
    else:
        print("No")

Solution (Python):
bingo = []
for i in range(3):
  bingo.append(input().split(' '))
  
n = int(input())

for j in range(n):
  b = input()
  for s in range(3):
    for t in range(3):
      if bingo[s][t] == b:
        bingo[s][t] = 'hit'
        
tenchi = [[0,0,0],[0,0,0],[0,0,0]]
for s in range(3):
  for t in range(3):
    tenchi[s][t] = bingo[t][s]
    
times = 0
for a in range(3):
  if bingo[a] == ['hit', 'hit', 'hit'] or tenchi[a] == ['hit', 'hit', 'hit']:
    times = 1
if (bingo[1][1] == 'hit' and bingo[2][2] == 'hit' and bingo[0][0] == 'hit') or (bingo[0][2] == 'hit' and bingo[1][1] == 'hit' and bingo[2][0] == 'hit'):
  times = 1

if times == 0:
  print('No')
else:
  print('Yes')

Solution (Python):
def main():
    bingo = []
    for i in range(3):
        a = list(map(int, input().split()))
        bingo.append(a)
    
    n = int(input())
    for j in range(n):
        b = int(input())

        for k in range(3):
            for l in range(3):
                if int(bingo[k][l]) == b:
                    bingo[k][l] = -1
    

    if [bingo[0][0],bingo[1][1],bingo[2][2]] == [-1,-1,-1] or [bingo[2][0],bingo[1][1],bingo[0][2]] == [-1,-1,-1]:
        print('Yes')
    else:
        for ii in range(3):    
            if bingo[ii][0:3] == [-1,-1,-1] or [bingo[0][ii],bingo[1][ii],bingo[2][ii]] == [-1,-1,-1]:
                
                print('Yes')
                break
        else:
            print('No')




if __name__ == '__main__':
    main()

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
bl = [int(input()) for _ in range(n)]
bingo = [[False, False, False] for _ in range(3)]
for b in bl:
    for i in range(3):
        if b in a[i]:
            bingo[i][a[i].index(b)] = True



yoko = [all(i) for i in bingo]


for i in range(3):
    for j in range(3):
        if bingo[j][i] == False:
            break
    else:
        tate = True
        break
else:
    tate = False


naname1 = False
for i in range(3):
    if bingo[i][i] == False:
        break
else:
    naname1 = True

naname2 = False
for i in range(3):
    if bingo[i][2-i] == False:
        break
else:
    naname2 = True

if True in yoko or tate or naname1 or naname2:
    print('Yes')
else:
    print('No')

Solution (Python):
card = [
    list(map(int, input().split(' '))),
    list(map(int, input().split(' '))),
    list(map(int, input().split(' ')))
]

count = int(input())

result = [[0 for _ in range(3)] for _ in range(3)]

for _ in range(count):
    b = int(input())
    for i, cc in enumerate(card):
        for j, c in enumerate(cc):
            if c == b:
                result[i][j] = 1

for i in range(3):
    if result[i][0] == result[i][1] == result[i][2] == 1:
        print('Yes')
        exit(0)
    if result[0][i] == result[1][i] == result[2][i] == 1:
        print('Yes')
        exit(0)
if result[0][0] == result[1][1] == result[2][2] == 1:
    print('Yes')
    exit(0)
if result[0][2] == result[1][1] == result[2][0] == 1:
    print('Yes')
    exit(0)
print('No')

Solution (Python):
mat = [[0 for i in range(3)] for j in range(3)]
for i in range(3):
    mat[i] = list(map(int, input().split()))

n = int(input())
for _ in range(n):
    b = int(input())
    for x in range(3):
        for y in range(3):
            if mat[x][y] == b:
                mat[x][y] = 101

flg = False
for x in range(3):
    if [mat[x][0], mat[x][1], mat[x][2]] == [101, 101, 101]:
        flg = True

for x in range(3):
    if [mat[0][x], mat[1][x], mat[2][x]] == [101, 101, 101]:
        flg = True

if [mat[0][0], mat[1][1], mat[2][2]] == [101, 101, 101]:
    flg = True

if [mat[0][2], mat[1][1], mat[2][0]] == [101, 101, 101]:
    flg = True

print("Yes") if flg else print("No")

Solution (Python):
card = [list(map(int,input().split())) for i in range(3)]
n = int(input())
numbers = [int(input()) for i in range(n)]


for number in numbers:
    for i in range(3):
        for j in range(3):
            if card[i][j] == number:
                card[i][j] = 0
    
bingo = False

for i in range(3):
    if card[i][0] == 0 and card[i][1] == 0 and card[i][2] == 0:
        bingo = True
    
for i in range(3):
    if card[0][i] == 0 and card[1][i] == 0 and card[2][i] == 0:
        bingo = True

if card[0][0] == 0 and card[1][1] == 0 and card[2][2] == 0:
    bingo = True
    
if card[0][2] == 0 and card[1][1] == 0 and card[2][0] == 0:
    bingo = True

if bingo:
    print('Yes')
else:
    print('No')

Solution (Python):
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
ans = 0

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

for i in range(0, N):
	b_input = int(input())
	b.append(b_input)

for i in range(0, 3):
	for j in range(0, N):
		if A_1[i] == b[j]:
			A_1[i] = True
		if A_2[i] == b[j]:
			A_2[i] = True
		if A_3[i] == b[j]:
			A_3[i] = True

A = [A_1, A_2, A_3]

for i in range(0, 3):
	if A[i][0] == A[i][1] == A[i][2] == True:
		ans = 1
		break
	elif A[0][i] == A[1][i] == A[2][i] == True:
		ans = 1
		break

if A[0][0] == A[1][1] == A[2][2] == True or A[0][2] == A[1][1] == A[2][0]:
	ans = 1

if ans == 1:
	print('Yes')
else:
	print('No')

Solution (Python):
bingo = [list(map(int,input().split())) for i in range(3)]
n = int(input())
num = [int(input()) for i in range(n)]
for i in num:
  for row in range(3):
    for col in range(3):
      if bingo[row][col] == i:
        bingo[row][col] = 0
if sum(bingo[0]) == 0 or sum(bingo[1]) == 0 or sum(bingo[2]) == 0 or sum([hoge[0] for hoge in bingo]) == 0 or sum([hoge[1] for hoge in bingo]) == 0 or sum([hoge[2] for hoge in bingo]) == 0 or sum([bingo[i][i] for i in range(3)]) == 0 or sum([bingo[i][2-i] for i in range(3)]) == 0:
  print('Yes')
else:
  print('No')

Solution (Python):
bingo = [list(map(int,input().split())) for i in range(3)]
n = int(input())
num = [int(input()) for i in range(n)]
for i in num:
  for row in range(3):
    for col in range(3):
      if bingo[row][col] == i:
        bingo[row][col] = 0
if sum(bingo[0]) == 0 or sum(bingo[1]) == 0 or sum(bingo[2]) == 0 or sum([hoge[0] for hoge in bingo]) == 0 or sum([hoge[1] for hoge in bingo]) == 0 or sum([hoge[2] for hoge in bingo]) == 0 or sum([bingo[i][i] for i in range(3)]) == 0 or sum([bingo[i][2-i] for i in range(3)]) == 0:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys
bingo = [list(map(int, input().split())) for i in range(3)]
N = int(input())

for i in range(N):
    b = int(input())
    for j in range(len(bingo)):
      for k in range(len(bingo[j])):
            if b == bingo[j][k]:
                bingo[j][k] = 0

for i in range(len(bingo)):
    if sum(bingo[i]) == 0:
        print('Yes')
        sys.exit()
    if (bingo[0][i] + bingo[1][i] + bingo[2][i]) == 0:
        print('Yes')
        sys.exit()

for i in [0]:
  if (bingo[i][i] + bingo[i+1][i+1] + bingo[i+2][i+2]) == 0:
    print('Yes')
    sys.exit()
  if (bingo[i][i+2] + bingo[i+1][i+1] + bingo[i+2][i]) == 0:
    print('Yes')
    sys.exit()
  else:
    print("No")

Solution (Python):








a = [0] * 9
i = 0
for i in range(3):
    b,c,d = map(int, input().split())
    
    a[3*i],a[3*i+1],a[3*i+2] = b,c,d

ans = 'No'

n = int(input())

b = [ int(input()) for i in range(n) ]

for i in range(n):
    for j in range(9):
        a[j] = -1 if b[i] == a[j] else a[j]

pairs = [
    [0,1,2],[3,4,5],[6,7,8],
    [0,3,6],[1,4,7],[2,5,8],
    [0,4,8],[2,4,6]]

for p in pairs:
    if a[p[0]] == -1 and a[p[1]] == -1 and a[p[2]] == -1:
        ans = 'Yes'


print(ans)

Solution (Python):
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
n=int(input())
b=[]
for i in range(n):
    b.append(int(input()))

for i in range(3):
    if a1[i] in b and a2[i] in b and a3[i] in b:
        print("Yes")
        exit()

if a1[0] in b and a1[1] in b and a1[2] in b:
    print("Yes")
    exit()
if a2[0] in b and a2[1] in b and a2[2] in b:
    print("Yes")
    exit()
if a3[0] in b and a3[1] in b and a3[2] in b:
    print("Yes")
    exit()

if a1[0] in b and a2[1] in b and a3[2] in b:
    print("Yes")
    exit()
if a1[2] in b and a2[1] in b and a3[0] in b:
    print("Yes")
    exit()

print("No")

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

for i in b:
    for j in A:
        if i in j:
            A[A.index(j)][j.index(i)] = -1
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == -1 or A[0][i] == A[1][i] == A[2][i] == -1:
        print('Yes')
        exit()
if A[0][0] == A[1][1] == A[2][2] == -1 or A[0][2] == A[1][1] == A[2][0] == -1:
    print('Yes')
    exit()
print('No')

Solution (Python):
datalist = [list(map (int, input().split(" "))) for i in range(3)]
checktbl = [[0,0,0],[0,0,0],[0,0,0]]
num = int(input())
for i in range(num):
    data = int(input())
    for j in range(3):
        for k in range(3):
            if datalist[k][j] == data:
                checktbl[k][j] = 1

result = "No"
for i in range(3):
    if checktbl[i][0] == 1 and checktbl[i][1] == 1 and checktbl[i][2] == 1:
        result = "Yes"
for i in range(3):
    if checktbl[0][i] == 1 and checktbl[1][i] == 1 and checktbl[2][i] == 1:
        result = "Yes"
if checktbl[0][0] == 1 and checktbl[1][1] == 1 and checktbl[2][2] == 1:
    result = "Yes"
if checktbl[0][2] == 1 and checktbl[1][1] == 1 and checktbl[2][0] == 1:
    result = "Yes"

print(result)

Solution (Python):
S="012 345 678 036 147 258 048 246 "
A=sum([input().split()for i in range(4)],[])
for b in [input()for i in range(int(A[9]))]:
  if b in A:
    S=S.replace(str(A.index(b)),"")
print("NYoe s"["  "in S::2])

Solution (Python):
S="012 345 678 036 147 258 048 246 "
A=sum([input().split()for i in range(4)],[])
for b in [input()for i in range(int(A[9]))]:
  if b in A:
    S=S.replace(str(A.index(b)),"")
print("YNeos"[not"  "in S::2])

Solution (Python):


a_l = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b_l = [int(input()) for i in range(n)]

for i in range(3):
    for j in range(3):
        for b in b_l:
            if a_l[i][j] == b:
                a_l[i][j] = 0

f = False

if a_l[0][0] == a_l[0][1] == a_l[0][2] == 0:
    f = True
elif a_l[1][0] == a_l[1][1] == a_l[1][2] == 0:
    f = True
elif a_l[2][0] == a_l[2][1] == a_l[2][2] == 0:
    f = True
elif a_l[0][0] == a_l[1][0] == a_l[2][0] == 0:
    f = True
elif a_l[0][1] == a_l[1][1] == a_l[2][1] == 0:
    f = True
elif a_l[0][2] == a_l[1][2] == a_l[2][2] == 0:
    f = True
elif a_l[0][0] == a_l[1][1] == a_l[2][2] == 0:
    f = True
elif a_l[0][2] == a_l[1][1] == a_l[2][0] == 0:
    f = True

if f:
    print('Yes')
else:
    print('No')

Solution (Python):


a_r_list = []
a_c_list = [[],[],[]]
a_table = []
for _ in range(3):
    a_list = list(map(int, input().split()))
    a_r_list.append(a_list)
    for i, a in enumerate(a_list):
        a_c_list[i].append(a)
    a_table.append(a_list)
a_list_list = a_r_list + a_c_list
a_list_list += [[a_table[0][0], a_table[1][1], a_table[2][2]]]
a_list_list += [[a_table[0][2], a_table[1][1], a_table[2][0]]]

N = int(input().split()[0])
is_ok = False
for _ in range(N):
    b = int(input().split()[0])
    for a_list in a_list_list:
        try:
            a_list.remove(b)
        except ValueError:
            pass
        if not a_list:
            is_ok = True
ans = "Yes" if is_ok else "No"
print(ans)

Solution (Python):
def main():
    num_list = []
    for _ in range(3):
        num_list.append(list(map(int,input().split())))
    n = int(input())
    b_list = [int(input()) for _ in range(n)]

    for i in range(3):
        for j in range(3):
            if num_list[i][j] in b_list:
                num_list[i][j] = '!'

    for i in range(3):
        count = 0
        for j in range(3):
            if num_list[i][j] == '!':
                count += 1
        if count == 3:
            print('Yes')
            exit()

    for i in range(3):
        count = 0
        for j in range(3):
            if num_list[j][i] == '!':
                count += 1
        if count == 3:
            print('Yes')
            exit()
    
    if num_list[0][0] == '!' and num_list[1][1] == '!' and num_list[2][2] == '!':
        print('Yes')
        exit()

    if num_list[0][2] == '!' and num_list[1][1] == '!' and num_list[2][0] == '!':
        print('Yes')
        exit()

    print('No')

if __name__ == '__main__':
    main()

Solution (Python):
S="012 345 678 036 147 258 048 246 "
A=sum([input().split()for i in range(4)],[])
for b in [input()for i in range(int(A[9]))]:
  if b in A:
    S=S.replace(str(A.index(b)),"")
print("YNeos"[S.find("  ")<0::2])

Solution (Python):
S="012 345 678 036 147 258 048 246 "
A=sum([input().split()for i in range(3)],[])
for b in [input()for i in range(int(input()))]:
  if b in A:
    S=S.replace(str(A.index(b)),"")
print("YNeos"[S.find("  ")<0::2])

Solution (Python):
S="012 345 678 036 147 258 048 246 "
A=sum([input().split()for i in range(3)],[])
for b in [input()for i in range(int(input()))]:
  if b in A:
    S=S.replace(str(A.index(b)),"")
print(["No","Yes"][S.find("  ")>-1])

Solution (Python):
S="012 345 678 036 147 258 048 246 "
A=[input().split()for i in range(3)]
B=A[0]+A[1]+A[2]
for b in [input()for i in range(int(input()))]:
  if b in B:
    S=S.replace(str(B.index(b)),"")
print(["No","Yes"][S.find("  ")>-1])

Solution (Python):
S="012 345 678 036 147 258 048 246 "
A=[input().split()for i in range(3)]
for b in [input()for i in range(int(input()))]:
  for l in range(9):
    S=S.replace(str([9,l][b==(A[0]+A[1]+A[2])[l]]),"")
print(["No","Yes"][S.find("  ")>-1])

Solution (Python):
S="012 345 678 036 147 258 048 246 "
A=[input().split()for i in range(3)]
B=A[0]+A[1]+A[2]
for b in [input()for i in range(int(input()))]:
  for l in range(9):
    S=S.replace(str([9,l][b==B[l]]),"")
print(["No","Yes"][S.find("  ")>-1])

Solution (Python):
S="012 345 678 036 147 258 048 246 "
A=[]
A.extend(list(map(int,input().split())) for i in range(3))
N=int(input())
for i in range(N):
  j=input()
  for l in range(3):
    for m in range(3):
      S=S.replace(str([9,l*3+m][A[l][m]==int(j)]),"")
print(["No","Yes"][S.find("  ")>-1])

Solution (Python):
A = [list(map(int, input().split())),
     list(map(int, input().split())),
     list(map(int, input().split()))]
 
N = int(input())
b = [int(input()) for _ in range(N)]

for a in A:
    if a[0] in b and a[1] in b and a[2] in b:
        print('Yes')
        exit()

for i in range(3):
    if A[0][i] in b and A[1][i] in b and A[2][i] in b:
        print('Yes')
        exit()

if A[0][0] in b and A[1][1] in b and A[2][2] in b:
    print('Yes')
    exit()

if A[0][2] in b and A[1][1] in b and A[2][0] in b:
    print('Yes')
    exit()

print('No')

Solution (Python):
lst = []
for i in range(3):
    s = list(map(int, input().split()))
    lst.append(s)
N = int(input())
for i in range(N):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if num == lst[j][k]:
                lst[j][k] = 0

for i in range(3):
    cnt = 0
    for j in range(3):
        if lst[i][j] == 0:
            cnt += 1
    if cnt == 3:
        print('Yes')
        exit()

for i in range(3):
    cnt = 0
    for j in range(3):
        if lst[j][i] == 0:
            cnt += 1
    if cnt == 3:
        print('Yes')
        exit()

cnt = 0
for i in range(3):
    if lst[i][i] == 0:
        cnt += 1
    if cnt == 3:
        print('Yes')
        exit()

if lst[0][2] == 0 and lst[1][1] == 0 and lst[2][0] == 0:
    print('Yes')
    exit()

print('No')

Solution (Python):
card = [list(map(int,input().split())) for i in range(3)]
N = int(input())
List = [int(input()) for i in range(N)]

def disclose(card, n, lst):
  for i in range(n):
    for j in range(3):
      for k in range(3):
        if card[j][k] == lst[i]:
          card[j][k] = 0
  return card
          
def trans(matrix):
  tr = []
  for i in range(len(matrix[0])):
    vector = []
    for j in range(len(matrix)):
      vector.append(matrix[j][i])
    tr.append(vector)
  return tr

def bingo(card):
  if card[0] == [0,0,0]:
    return True
  if card[1] == [0,0,0]:
    return True
  if card[2] == [0,0,0]:
    return True
  card = trans(card)
  if card[0] == [0,0,0]:
    return True
  if card[1] == [0,0,0]:
    return True
  if card[2] == [0,0,0]:
    return True
  for i in range(3):
    if card[i][i] != 0:
      break
    if i == 2:
      return True
  for i in range(3):
    if card[i][2-i] != 0:
      break
    if i == 2:
      return True
  return False
    
def judge(x):
  if x:
    return "Yes"
  return "No"

print(judge(bingo(disclose(card, N, List))))

Solution (Python):
import sys
input = sys.stdin.readline

class Bingo():
    def __init__(self, board):
        self.board = board
        self.length = 3
        self.check = [[False] * self.length for i in range(self.length)]
    
    def punch(self, num):
        for i in range(self.length):
            for j in range(self.length):
                if self.board[i][j] == num:
                    self.check[i][j] = True

    def bingo_count(self):
        ret = 0
        
        for i in range(self.length):
            ok = True
            for j in range(self.length):
                if not self.check[i][j]:
                    ok = False
                    break
            if ok:
                ret += 1
        
        for i in range(self.length):
            ok = True
            for j in range(self.length):
                if not self.check[j][i]:
                    ok = False
                    break
            if ok:
                ret += 1
        
        ok = True
        for i in range(self.length):
            if not self.check[i][i]:
                ok = False
                break
        if ok:
            ret += 1
        
        ok = True
        for i in range(self.length):
            if not self.check[i][-i-1]:
                ok = False
                break
        if ok:
            ret += 1
        
        return ret

def main():
    bingo = Bingo([list(map(int, input().split())) for i in range(3)])
    N = int(input())

    for _ in range(N):
        b = int(input())
        bingo.punch(b)
    
    if bingo.bingo_count() > 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Solution (Python):
A = [list(map(int, input().split())),
     list(map(int, input().split())),
     list(map(int, input().split()))]

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

for a in A:
    if a[0] in B and a[1] in B and a[2] in B:
        print('Yes')
        exit()

for i in range(3):
    if A[0][i] in B and A[1][i] in B and A[2][i] in B:
        print('Yes')
        exit()

if A[0][0] in B and A[1][1] in B and A[2][2] in B:
    print('Yes')
    exit()

if A[0][2] in B and A[1][1] in B and A[2][0] in B:
    print('Yes')
    exit()

print('No')

Solution (Python):
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=list(int(input()) for i in range(n))
ans="No"

for i in range(n):
  for j in range(3):
    for k in range(3):      
    	if b[i]==a[j][k]:
      		a[j][k]=-1
for i in range(3):
  if a[i]==[-1,-1,-1]:
    ans="Yes"
    break
for i in range(3):
  if a[0][0]==a[1][1]==a[2][2]==-1:
    ans="Yes"
    break
if a[2][0]==a[1][1]==a[0][2]==-1:
  ans="Yes"
if a[0][0]==a[1][0]==a[2][0]==-1 or a[0][1]==a[1][1]==a[2][1]==-1 or a[0][2]==a[1][2]==a[2][2]==-1:
	ans="Yes"
print(ans)

Solution (Python):
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

yoko1 = [a[0][0],a[0][1],a[0][2]]
yoko2 = [a[1][0],a[1][1],a[1][2]]
yoko3 = [a[2][0],a[2][1],a[2][2]]
tate1 = [a[0][0],a[1][0],a[2][0]]
tate2 = [a[0][1],a[1][1],a[2][1]]
tate3 = [a[0][2],a[1][2],a[2][2]]
naname1 = [a[0][0],a[1][1],a[2][2]]
naname2 = [a[0][2],a[1][1],a[2][0]]
count = 0
d = [yoko1,yoko2,yoko3,tate1,tate2,tate3,naname1,naname2]
for i in range(8):
    if d[i][0] in b and d[i][1] in b and d[i][2] in b:
        count = 1
        break
if count == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
A = []
A11,A12,A13 = map(int, input().split())
A21,A22,A23 = map(int, input().split())
A31,A32,A33 = map(int, input().split())
N = int(input())
B = []
for i in range(N):
  B.append(int(input()))
  
A = [[A11,A12,A13],
     [A21,A22,A23],
     [A31,A32,A33]]

sets = []

for i in range(3):
  s = []
  for j in range(3):
  	s.append(A[i][j])
  sets.append(s)
  
for j in range(3):
  s = []
  for i in range(3):
  	s.append(A[i][j])
  sets.append(s)
  
sets.append([A11,A22,A33])
sets.append([A13,A22,A31])

for s in sets:
  count = 0
  for b in B:
    if b in s : 
      count+=1
  if count == 3:
    print("Yes")
    break
else:
  print("No")

Solution (Python):
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=list(int(input()) for i in range(n))

bingo="No"

for k in range(n):
  for i in range(3):
    for j in range(3):
      if b[k]==a[i][j]:
        a[i][j]=0
        
for i in range(3):
  if a[i]==[0,0,0]:bingo="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:bingo="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:bingo="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:bingo="Yes"

print(bingo)