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):

a1, a2, a3 = [input().split() for l in range(3)]
n = int(input())
b = [input() for i in range(n)]

var1 = []
var2 = []
var3 = []

for bb in b:
    if bb in a1:
        var1.append(a1.index(bb))

    elif bb in a2:
        var2.append(a2.index(bb))
    elif bb in a3:
        var3.append(a3.index(bb))


if 0 in var1 and 0 in var2 and 0 in var3 or 1 in var1 and 1 in var2 and 1 in var3 or 2 in var1 and 2 in var2 and 2 in var3 :
    print("Yes")


elif 0 in var1 and 1 in var1 and 2 in var1 or 0 in var2 and 1 in var2 and 2 in var2 or 0 in var3 and 1 in var3 and 2 in var3 :
    print("Yes")


elif 0 in var1 and 1 in var2 and 2 in var3 or 2 in var1 and 1 in var2 and 0 in var3:
    print("Yes")

else : 
    print("No")

Solution (Python):
import numpy as np
li = [list(map(int, input().split())) for i in range(3)] 
N = int(input())
B_list = [list(map(int, input().split())) for i in range(N)] 

arr = np.array(li)
arr2 = np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]])






for i in range(N):
    for j in range(3):
        for k in range(3):
            if arr[j, k] == B_list[i]:
                arr2[j, k] = 0



if arr2[0, 0] == 0 and arr2[0, 1] == 0 and arr2[0, 2] == 0:
    print("Yes")
    exit()
elif arr2[1, 0] == 0 and arr2[1, 1] == 0 and arr2[1, 2] == 0:
    print("Yes")
    exit()
elif arr2[2, 0] == 0 and arr2[2, 1] == 0 and arr2[2, 2] == 0:
    print("Yes")
    exit()
elif arr2[0, 0] == 0 and arr2[1, 0] == 0 and arr2[2, 0] == 0:
    print("Yes")
    exit()
elif arr2[0, 1] == 0 and arr2[1, 1] == 0 and arr2[2, 1] == 0:
    print("Yes")
    exit()
elif arr2[0, 2] == 0 and arr2[1, 2] == 0 and arr2[2, 2] == 0:
    print("Yes")
    exit()
elif arr2[0, 0] == 0 and arr2[1, 1] == 0 and arr2[2, 2] == 0:
    print("Yes")
    exit()
elif arr2[0, 2] == 0 and arr2[1, 1] == 0 and arr2[2, 0] == 0:
    print("Yes")
    exit()
else:
    print("No")

Solution (Python):
mat=[]

for i in range(3):
    inp = [int(x) for x in input().split()]
    mat.append(inp)
    
n = int(input())

for _ in range(n):
    q = int(input())
    for i in range(3):
        if q in mat[i]:
            ind = mat[i].index(q)
            mat[i][ind] = '1'
            break
    
if mat[0][0]=='1' and mat[0][1]=='1' and mat[0][2]=='1':
    print('Yes')
    
elif mat[1][0]=='1' and mat[1][1]=='1' and mat[1][2]=='1':
    print('Yes')

elif mat[2][0]=='1' and mat[2][1]=='1' and mat[2][2]=='1':
    print('Yes')


elif mat[0][0]=='1' and mat[1][0]=='1' and mat[2][0]=='1':
    print('Yes')

elif mat[0][1]=='1' and mat[1][1]=='1' and mat[2][1]=='1':
    print('Yes')

elif mat[0][2]=='1' and mat[1][2]=='1' and mat[2][2]=='1':
    print('Yes')


elif mat[0][0]=='1' and mat[1][1]=='1' and mat[2][2]=='1':
    print('Yes')

elif mat[0][2]=='1' and mat[1][1]=='1' and mat[2][0]=='1':
    print('Yes')
else:
    print('No')

Solution (Python):
b=[]
for i in range(3):
  a = input().split()
  b.append(a)
n = int(input())
c=[0]*n
for i in range(n):
  c[i]=input()
hantei = "No"
for i in range(n):
  for x in range(3):
    for y in range(3):
      if b[y][x] == c[i]:
        b[y][x] = 101
for i in range(3):
  if b[i][0] == 101 and b[i][1] == 101 and b[i][2] == 101:
    hantei = "Yes"
  elif b[0][i] == 101 and b[1][i] == 101 and b[2][i] == 101:
    hantei = "Yes"
  elif b[0][0] == 101 and b[1][1] == 101 and b[2][2] == 101:
    hantei = "Yes"
  elif b[0][2] == 101 and b[1][1] == 101 and b[2][0] == 101:
    hantei = "Yes"
print(hantei)

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

n = int(input())
for i in range(n):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if b[j][k] == num:
                a[j][k] = True

flag = 0
for i in range(3):
    f = 1
    for j in range(3):
        if not a[i][j]:
            f = 0
    if f == 1:
        flag = 1

for j in range(3):
    f = 1
    for i in range(3):
        if not a[i][j]:
            f = 0
    if f == 1:
        flag = 1

if a[0][0] and a[1][1] and a[2][2]:
    flag = 1
if a[2][0] and a[1][1] and a[0][2]:
    flag = 1

if flag == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
import numpy as np


a=np.array([sys.stdin.readline().split() for _ in range(3)],dtype='int64')
n=int(sys.stdin.readline())
b=np.array([sys.stdin.readline() for _ in range(n)],dtype='int64')

for bi in b:
    a=np.where(a==bi,0,a)
ans=0

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

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

Solution (Python):
def isBingo(a):
    for i in range(3):
        if a[i][0] == a[i][1] and a[i][0] == a[i][2] and a[i][0] == -1:
            return 'Yes'
        elif a[0][i] == a[1][i] and a[0][i] == a[2][i] and a[0][i] == -1:
            return 'Yes'
    if a[0][0] == a[1][1] and a[0][0] == a[2][2] and a[0][0] == -1:
        return 'Yes'
    elif a[0][2] == a[1][1] and a[0][2] == a[2][0] and a[0][2] == -1:
        return 'Yes'
    else:
        return 'No'
    
a = []
for i in range(3):
    a.append(list(map(int, input().split())))
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

for i in range(n):
    for j in range(3):
        if b[i] in a[j]:
            a[j][a[j].index(b[i])] = -1

print(isBingo(a))

Solution (Python):
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
N = int(input())
num = []
for _ in range(N):
  num.append(int(input()))
  
bingo = [
  [a11, a12, a13], 
  [a21, a22, a23], 
  [a31, a32, a33]
]
 
for n in range(3):
  for m in range(3): 
    if bingo[n][m] in num:
      bingo[n][m] = 0
 
row1 = bingo[0][0] + bingo[0][1] + bingo[0][2]
row2 = bingo[1][0] + bingo[1][1] + bingo[1][2]
row3 = bingo[2][0] + bingo[2][1] + bingo[2][2]
 
col1 = bingo[0][0] + bingo[1][0] + bingo[2][0]
col2 = bingo[0][1] + bingo[1][1] + bingo[2][1]
col3 = bingo[0][2] + bingo[1][2] + bingo[2][2]
 
cross1 = bingo[0][0] + bingo[1][1] + bingo[2][2]
cross2 = bingo[2][0] + bingo[1][1] + bingo[2][0]
 
if 0 in [row1, row2, row3, col1, col2, col3, cross1, cross2]:
  print("Yes")
else:
  print("No")

Solution (Python):



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

n = int(input())

for _ in range(n):  
   b = int(input())
   for i in range(3):
    for j in range(3):
      if b == a[i][j]:
        a[i][j] = 0  
        
for i in range(3):
    bingo = False
    if sum(a[i]) == 0: 
     print("Yes")
     exit()
    if sum([a[0][i], a[1][i], a[2][i]]) == 0: 
     print("Yes")
     exit()

if sum([a[0][0], a[1][1], a[2][2]]) == 0: 
    print("Yes")
    exit()

if sum([a[2][0], a[1][1], a[0][2]]) == 0: 
    print("Yes")
    exit()


print("No")

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

s = set()
n = int(input())
for i in range(0,n):
    s.add(int(input()))
    
for i in range(0,3):
    for j in range(0,3):
        if a[i][j] in s:
            b[i][j] = 1
        else:
            b[i][j] = 0
            
b1 = b[0][0]*b[0][1]*b[0][2]
b2 = b[1][0]*b[1][1]*b[1][2]
b3 = b[2][0]*b[2][1]*b[2][2]
b4 = b[0][0]*b[1][0]*b[2][0]
b5 = b[0][1]*b[1][1]*b[2][1]
b6 = b[0][2]*b[1][2]*b[2][2]
b7 = b[0][0]*b[1][1]*b[2][2]
b8 = b[2][0]*b[1][1]*b[0][2]


if (b1 or b2 or b3 or b4 or b5 or b6 or b7 or b8) == 1:
	print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
import itertools
A = np.array([[0]*3 for i in range(3)])
for i in range(3):
    A[i] = list(map(int, input().split()))
    
N = int(input())

b = np.array([0]*N)
for i in range(N):
    b[i] = int(input())
    
arr = np.array([[0]*3 for i in range(3)])

for i, x, y in itertools.product(range(N), range(3), range(3)):
    if A[x][y] == b[i]:
        arr[x][y] = 1

flag = False
for i in range(3):
    if sum(arr[i]) == 3:
        flag = True

for i in range(3):
    if sum(arr[:,i]) == 3:
        flag = True
        
if arr[0][0] + arr[1][1] + arr[2][2] == 3:
    flag = True

if arr[0][2] + arr[1][1] + arr[2][0] == 3:
    flag = True
    
if flag:
    print('Yes')
else:
    print('No')

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

n = int(input())
for _ in range(n):
  b = int(input())

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

for i in range(3):
  bingo = False
  if sum(a[i]) == 0:
    print('Yes')
    exit()
  if sum([a[0][i], a[1][i], a[2][i]]) == 0:
    print('Yes')
    exit()
if sum([a[0][0], a[1][1], a[2][2]]) == 0:
  print('Yes')
  exit()
if sum([a[2][0], a[1][1], a[0][2]]) == 0:
  print('Yes')
  exit()
print('No')

Solution (Python):
a_1 = [int(i) for i in input().split()]
a_2 = [int(i) for i in input().split()]
a_3 = [int(i) for i in input().split()]
n = int(input())


def chikan(b, items):
    return [True if i == b else i for i in items]


def alls(iterable):
    for element in iterable:
        if not type(element) is bool:
            return False
    return True


for i in range(n):
    b = int(input())
    a_1 = chikan(b, a_1)
    a_2 = chikan(b, a_2)
    a_3 = chikan(b, a_3)

a_4 = [a_1[0], a_2[0], a_3[0]]
a_5 = [a_1[1], a_2[1], a_3[1]]
a_6 = [a_1[2], a_2[2], a_3[2]]
a_7 = [a_1[0], a_2[1], a_3[2]]
a_8 = [a_1[2], a_2[1], a_3[0]]

if any([alls(a_1), alls(a_2), alls(a_3), alls(a_4), alls(a_5), alls(a_6), alls(a_7), alls(a_8)]):
    print('Yes')
else:
    print('No')

Solution (Python):
A = []
check = [[0,0,0],
         [0,0,0],
         [0,0,0]]
for i in range(3):
    A.append(list(map(int,input().split())))
N = int(input())
for i in range(N):
    p = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == p:
                check[j][k] = 1

flag = 0
for i in range(3):
    if check[i][0] == 1 and check[i][1] == 1 and check[i][2] == 1:
        flag = 1
    if check[0][i] == 1 and check[1][i] == 1 and check[2][i] == 1:
        flag = 1
if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
    flag = 1
if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
    flag = 1

if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
A = []
B = [0]*9


for _ in range(3):
    A += [int(i) for i in input().split()]


n=int(input())
for _ in range(n):
    b = int(input())
    for i, a in enumerate(A):
        if b == a:
            B[i] = 1


C = [[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[3,5,7]]
flag = 0


for a,b,c in C:
    if B[a-1] and B[b-1] and B[c-1]:
        flag = 1
print('Yes' if flag else 'No')

Solution (Python):
a=[]
d={}
for _ in range(3):
	a.append(list(map(int,input().split())))
for i in range(3):
	for j in range(3):
		d[a[i][j]]=[i,j]
n=int(input())
b=[]
for _ in range(n):
	t=int(input())
	if t in d:
		a[d[t][0]][d[t][1]]=0
f=0
for i in range(3):
	if(a[i][0]==0 and a[i][1]==0 and a[i][2]==0):
		f=1
		break
for i in range(3):
	if(a[0][i]==0 and a[1][i]==0 and a[2][i]==0):
		f=1
		break
if(a[0][0]==0 and a[1][1]==0 and a[2][2]==0):
	f=1
if(a[0][2]==0 and a[1][1]==0 and a[2][0]==0):
	f=1
if f==1:
	print("Yes")
else:
	print("No")

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

N = int(input())
blist = []
for i in range(N):
    blist.append(int(input()))
bset = set(blist)

aplist = [
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 4, 8],
    [2, 4, 6]
    ]
cset = set()

for i, n in enumerate(bingo):
    if n in bset:
        cset.add(i)
        
    


for tests in aplist:
    isok = True
    for test in tests:
        if test not in cset:
            isok = False
            break
    if isok:
        print("Yes")
        
        exit()
print("No")

Solution (Python):

a = []
b = []
for i in range(3):
    a2 = list(map(int,input().split()))
    a.append(a2)
n = int(input())
c = [0 for i in range(8)]
ok = False

for i in range(n):
    b.append(int(input()))
b = set(b)

for p in b:
    
    
    for j in range(3):
        for k in range(3):
            if a[j][k] == p:
                
                c[j] += 1
                
    
    for k in range(3):
        for j in range(3):
            if a[j][k] == p:
                c[k+3] +=1
                
    
    for l in range(3):
        if a[l][l] == p:
            c[6] += 1

    for m in range(3):
        if a[m][int(2-m)] == p:
            c[7] += 1

if str(3) in str(c):
    print("Yes")
else:
    print("No")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    tf = [[False, False, False], [False, False, False], [False, False, False]]
    for num in b:
        for i in range(3):
            for j in range(3):
                tf[i][j] |= A[i][j] == num

    bingo = True
    for i in range(3):
        for j in range(3):
            bingo &= tf[i][j]
        if bingo:
            print(YES)
            return
        else:
            bingo = True

    bingo = True
    for j in range(3):
        for i in range(3):
            bingo &= tf[i][j]
        if bingo:
            print(YES)
            return
        else:
            bingo = True

    bingo1 = True
    bingo2 = True
    for i in range(3):
        bingo1 &= tf[i][i]
        bingo2 &= tf[i][2-i]

    if bingo1 or bingo2:
        print(YES)
        return
    else:
        print(NO)
        return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)

if __name__ == '__main__':
    main()

Solution (Python):
def create_hole(A: list, b:list):

    N = len(A)
    Hole = [[0 for i in range(N)] for j in range(N)]
    for i in range(3):
        for j in range(3):
            for value in b:
                if A[i][j] == value: Hole[i][j] = 1

    return Hole


def check_bingo(H: list):

    N = len(H)
    rowsum = sum([sum(row) == N for row in H])
    colsum = sum([sum(row) == N for row in map(list, zip(*H))])
    digsum = sum([H[i][i] for i in range(N)]) == N
    tdigsum = sum([H[i][N-i-1] for i in range(N)]) == N

    return rowsum + colsum + digsum + tdigsum > 0


def resolve():

    A = [list(map(int, input().split())) for i in range(3)]
    N = int(input())
    b = [int(input()) for i in range(N)]
    print('Yes' if check_bingo(create_hole(A, b)) else 'No')
    
resolve()

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

N = int(input())        

result = [[0,0,0],[0,0,0],[0,0,0]]      
for _ in range(N):      
    b = int(input())        
    for i in range(3):      
        for j in range(3):
            if b == card[i][j]:
                result[i][j] = 1

judge = "No"        

for i in range(3):      
    if result[i][0] * result[i][1] * result[i][2] == 1:
        judge = "Yes"

for i in range(3):      
    if result[0][i] * result[1][i] * result[2][i] == 1:
        judge = "Yes"

if result[0][0] * result[1][1] * result[2][2] == 1:     
    judge = "Yes"

if result[0][2] * result[1][1] * result[2][0] == 1:     
    judge = "Yes"

print(judge)

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

n = int(input())

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

arr = [[0] * 3 for i in range(3)]
for i in range(n):
    for x in range(3):
        for y in range(3):
            if a[x][y] == b[i]:
                arr[x][y] = 1
flag = False
for x in range(3):
    count = 0
    for y in range(3):
        count += arr[x][y]
    if count == 3:
        flag = True

for x in range(3):
    count = 0
    for y in range(3):
        count += arr[y][x]
    if count == 3:
        flag = True

if arr[0][0] + arr[1][1] + arr[2][2] == 3:
    flag = True

if arr[0][2] + arr[1][1] + arr[2][0] == 3:
    flag = True

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

Solution (Python):
grid =  [list(map(int, input().split())) for i in range(3)]
n = int(input())
possi = []
for i in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if grid[i][j] == b:
                grid[i][j] = 0
can = True
for i in range(3):
    possi.append([grid[i][0], grid[i][1], grid[i][2]])
for i in range(3):
    possi.append([grid[0][i], grid[1][i], grid[2][i]])
possi.append([grid[0][0], grid[1][1], grid[2][2]])
possi.append([grid[0][2], grid[1][1], grid[2][0]])
for a, b, c in possi:
    if a == 0 and b == 0 and c== 0:
        print("Yes")
        can = False
        break
if can:
    print("No")

Solution (Python):

import numpy as np

A = np.array([list((int(_) for _ in input().split())) for x in range(3)])
N = int(input())
b = {int(input()) for _ in range(N)}

ans = "No"
for i in range(3):
    if (set(A[i, :]) <= b) or (set(A[:, i]) <= b):
        ans = "Yes"
if ({A[0][0], A[1][1], A[2][2]} <= b) or ({A[0][2], A[1][1], A[2][0]} <= b):
    ans = "Yes"

print(ans)

Solution (Python):
import sys

li1 = list(map(int,input().split()))
li2 = list(map(int,input().split()))
li3 = list(map(int,input().split()))
n=int(input())
call = [int(input()) for i in range(n)]

li1.extend(li2)
li1.extend(li3)

bingo=[0,0,0,0,0,0,0,0,0]

for num in call:
    if num in li1:
        ind = li1.index(num)
        bingo[ind] = 1

if bingo[0] == bingo[1] == bingo[2] == 1:
    print('Yes')
    sys.exit()

if bingo[3] == bingo[4] == bingo[5] == 1:
    print('Yes')
    sys.exit()

if bingo[6] == bingo[7] == bingo[8] == 1:
    print('Yes')
    sys.exit()

if bingo[0] == bingo[3] == bingo[6] == 1:
    print('Yes')
    sys.exit()

if bingo[1] == bingo[4] == bingo[7] == 1:
    print('Yes')
    sys.exit()

if bingo[2] == bingo[5] == bingo[8] == 1:
    print('Yes')
    sys.exit()

if bingo[0] == bingo[4] == bingo[8] == 1:
    print('Yes')
    sys.exit()

if bingo[2] == bingo[4] == bingo[6] == 1:
    print('Yes')
    sys.exit()

print('No')

Solution (Python):
import numpy as np

a = np.array([list((int(_) for _ in input().split())) for x in range(3)])
n = int(input())
b = {int(input()) for _ in range(n)}

wk = "No"
for i in range(3):
    if (set(a[i, :]) <= b) or (set(a[:, i]) <= b):
        wk = "Yes"
if ({a[0][0], a[1][1], a[2][2]} <= b) or ({a[0][2], a[1][1], a[2][0]} <= b):
    wk = "Yes"
print(wk)

Solution (Python):
a,b,c = input().split()
d,e,f = input().split()
g,h,i = input().split()
N = int(input())

A = []
B = [a,b,c,d,e,f,g,h,i]
F =[]
q = 0
E = True

for X in range(N):
    A.append(input())
    
for Y in range(N):
    V = A[q] in B
    if V == E:
        F.append(B.index(A[q]))
        q += 1
    else:
        q += 1
W = sorted(F)
if B.index(a) in W and B.index(b) in W and B.index(c) in W:
    print('Yes')
elif B.index(d) in W and B.index(e) in W and B.index(f) in W:
    print('Yes')
elif B.index(g) in W and B.index(h) in W and B.index(i) in W:
    print('Yes')
elif B.index(a) in W and B.index(d) in W and B.index(g) in W:
    print('Yes')
elif B.index(b) in W and B.index(e) in W and B.index(h) in W:
    print('Yes')
elif B.index(c) in W and B.index(f) in W and B.index(i) in W:
    print('Yes')
elif B.index(a) in W and B.index(e) in W and B.index(i) in W:
    print('Yes')
elif B.index(c) in W and B.index(e) in W and B.index(g) in W:
    print('Yes')
else:
    print('No')

Solution (Python):
x=list(map(int,input().split()))
y=list(map(int,input().split()))
z=list(map(int,input().split()))
A=[x,y,z]
X=[A[0][0],A[1][0],A[2][0]]
Y=[A[0][1],A[1][1],A[2][1]]
Z=[A[0][2],A[1][2],A[2][2]]
P=[A[0][0],A[1][1],A[2][2]]
Q=[A[0][2],A[1][1],A[2][0]]
B=[]
for i in range(int(input())):
    B.append(int(input()))
C=[x,y,z,X,Y,Z,P,Q]
for c in C:
    if set(c)<=set(B):
        print("Yes")
        break
else:
    print("No")

Solution (Python):
A = [input().split() for i in range(3)]
N = int(input())
b = [input() for i in range(N)]
f = False

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

for i in range(3):
    if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
        f = True
    elif A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        f = True

if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    f = True
elif A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
    f = True

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

Solution (Python):


first_array = [int(i) for i in input().split()]
second_array = [int(i) for i in input().split()]
third_array = [int(i) for i in input().split()]
N = int(input())
bs = []
for i in range(N):
    bs.append(int(input()))

first_array = [(i in bs) for i in first_array]
second_array = [(i in bs) for i in second_array]
third_array = [(i in bs) for i in third_array]
check_array = [True for i in range(3)]
bingo = [first_array, second_array, third_array]


def main():
    bingo_count = int()
    
    for horizon in bingo:
        bingo_count += int(horizon == check_array)

    
    for i in range(3):
        vertical = []
        for j in range(3):
            vertical.append(bingo[j][i])
        bingo_count += int(vertical == check_array)

    
    diagnal = [bingo[i][i] for i in range(3)]
    bingo_count += int(diagnal == check_array)

    
    diagnal = [bingo[i][up] for up,i in enumerate(reversed(range(3)))]
    bingo_count += int(diagnal == check_array)
    
    
    if bingo_count > 0:
        print("Yes")
    else:
        print("No")
main()

Solution (Python):

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

n = int(input())

for i in range(n):
    b = int(input())
    for ai in A:
        if b in ai:
            ai[ai.index(b)] = None

for i in range(3):
    if A[i] == [None, None, None]:
        bingo = 1

    if [A[0][i], A[1][i], A[2][i]] == [None, None, None]:
        bingo = 1

if [A[0][0], A[1][1], A[2][2]] == [None, None, None] or [A[0][2], A[1][1], A[2][0]] == [None, None, None]:
    bingo = 1

print("Yes") if bingo == 1 else print("No")

Solution (Python):
card = [input().split() for i in range(3)]
N = int(input())
idx = [0, 1, 2]

for i in range(N):
    tmp = str(input())
    for i in idx:
        if tmp in card[i]:
            card[i][card[i].index(tmp)] = "x"


is_True = False
d = {0: 0, 1: 0, 2: 0}
diago_r = {0: 0, 1: 0, 2: 0}
diago_l = {2: 0, 1: 0, 0: 0}



for j in idx:  
    if card[j].count("x") == 3:
        is_True = True
        break

for j in idx:  
    for k in idx:  
        if card[j][k] == "x":
            d[k] += 1
            if j == 0 and (k == 0 or k == 2):
                if k == 0:
                    diago_r[0] += 1
                else:
                    diago_l[2] += 1
            elif j == 1 and k == 1:
                diago_r[1] += 1
                diago_l[1] += 1
            elif j == 2 and (k == 0 or k == 2):
                if k == 0:
                    diago_l[0] += 1
                else:
                    diago_r[2] += 1

if is_True:
    pass
else:
    for a in d.values():
        if a == 3:
            is_True = True
        elif diago_r[0] == diago_r[1] == diago_r[2] == 1:
            is_True = True
        elif diago_l[0] == diago_l[1] == diago_l[2] == 1:
            is_True = True

if is_True:
    print("Yes")
else:
    print("No")

Solution (Python):
a = [[], [], []]
a[0] = list(map(int, input().split()))
a[1] = list(map(int, input().split()))
a[2] = list(map(int, input().split()))
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if b == a[j][k]:
                a[j][k] = 0
flag = False
for i in range(3):
    if sum(a[i]) == 0 or a[0][i] + a[1][i] + a[2][i] == 0:
        flag = True
if a[0][0] + a[1][1] + a[2][2] == 0 or a[0][2] + a[1][1] + a[2][0] == 0:
    flag = True
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
if __name__ == '__main__':
    m = [input() for _ in range(3)]
    n = input()
    a = [int(input()) for _ in range(int(n))]
    c =[]
    for i in m:
        b = [int(j) for j in i.split()]
        c.append(b)

    for n,i in enumerate(c):
        for m,j in enumerate(i):
            if j in a:
                c[n][m] = -1
                
    re = []
    for i in range(3):
        tmp = []
        tmp2 = []
        for j in range(3):
            tmp.append([i,j])
            tmp2.append([j,i])
        re.append(tmp)
        re.append(tmp2)
    re.append([[0,2],[1,1],[2,0]])
    re.append([[0,0],[1,1],[2,2]])

    f = 0
    for i in re:
        flg =[]
        for n,j in enumerate(i):
            if c[j[0]][j[1]] == -1:
                flg.append(1)
            else:
                flg.append(0)
        if flg == [1,1,1]:
            f = 1
    
    if f == 1:
        print('Yes')
    else:
        print('No')

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

N = int(input())

result = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == card[i][j]:
                result[i][j] = 1

judge = 'No'

for i in range(3):
    if result[i][0] * result[i][1] * result[i][2] == 1:
        judge = 'Yes'

for i in range(3):
    if result[0][i] * result[1][i] * result[2][i] == 1:
        judge = 'Yes'

if result[0][0] * result[1][1] * result[2][2] == 1:
    judge = 'Yes'

if result[0][2] * result[1][1] * result[2][0] == 1:
    judge = 'Yes'

print(judge)

Solution (Python):

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

n = int(input())

for i in range(n):
    b = int(input())
    for ai in A:
        if b in ai:
            ai[ai.index(b)] = None

for i in range(3):
    if A[i] == [None, None, None]:
        bingo = 1

    if [A[0][i], A[1][i], A[2][i]] == [None, None, None]:
        bingo = 1

if [A[0][0], A[1][1], A[2][2]] == [None, None, None] or [A[0][2], A[1][1], A[2][0]] == [None, None, None]:
    bingo = 1

print("Yes") if bingo == 1 else print("No")

Solution (Python):
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
a=[[False]*3 for i in range(3)]
for i in range(3):
    for j in range(3):
        for b in B:
            if A[i][j]==b:
                a[i][j]=True
bingo=False
for i in range(3):
    if a[i][0] and a[i][1] and a[i][2]:
        bingo=True
for j in range(3):
    if a[0][j] and a[1][j] and a[2][j]:
        bingo=True
if a[0][0] and a[1][1] and a[2][2]:
    bingo=True
if a[2][0] and a[1][1] and a[2][0]:
    bingo=True
print("Yes" if bingo else "No")

Solution (Python):
import sys

A = []

flag_First = True
for Count in range(3):
    for x in input().split(' '):
        x.strip('\n')
        InputValue = int(x)
        if 1<=int(x)<=100:
            if flag_First==True:
                A.append (InputValue)
                flag_First = False
            else:
                for Index in A:
                    if Index == InputValue:
                        print('No')
                        sys.exit()

                A.append (InputValue)
        else:
            print('No')
            sys.exit()

N = int(input())
if N<=0 and N>10:
    print('No')
    sys.exit()

B = []
for Count in range(1,N+1):
    InputValue = int(input())
    if 1<=InputValue<=100:
        if Count == 1:
            B.append (InputValue)
        else:
            for Index in B:
                if Index == InputValue:
                    print('No')
                    sys.exit()

            B.append (InputValue)

Bingo =[0,0,0,0,0,0,0,0,0]

for Item_B in B:
    for Index,Item_A in enumerate(A):
        if Item_A == Item_B:
            Bingo[Index]= 1

def CheckHorizontalBingo(Start,End):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Start<=Index<=End:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('Yes')
        sys.exit()

CheckHorizontalBingo(0,2)
CheckHorizontalBingo(3,5)
CheckHorizontalBingo(6,8)

def CheckVerticalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('Yes')
        sys.exit()

CheckVerticalBingo(0,3,6)
CheckVerticalBingo(1,4,7)
CheckVerticalBingo(2,5,8)

def CheckDiagonalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('Yes')
        sys.exit()

CheckDiagonalBingo(0,4,8)
CheckDiagonalBingo(2,4,6)

print('No')

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

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

flag = False
if A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0:
    flag = True
if A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0:
    flag = True
if A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0:
    flag = True
if A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0:
    flag = True
if A[1][0] == 0 and A[1][1] == 0 and A[1][2] == 0:
    flag = True
if A[2][0] == 0 and A[2][1] == 0 and A[2][2] == 0:
    flag = True
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    flag = True
if A[0][2] == 0 and A[1][1] == 0 and A[0][2] == 0:
    flag = True

if flag:
    print("Yes")
else:
    print("No")