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):
bingo = []
bingo_ans = []
d = {}
for _ in range(3):
  bingo.append(list(map(int, input().split())))
  bingo_ans.append([False]*3)
  
n = int(input())
  
for _ in range(n):
  i = int(input())
  for j in range(3):
    if i in bingo[j]:
      index = bingo[j].index(i)
      bingo_ans[j][index] = True

ans = "No"

for i in range(3):
  if bingo_ans[i][0] and bingo_ans[i][1] and bingo_ans[i][2]:
    ans = "Yes"
  if bingo_ans[0][i] and bingo_ans[1][i] and bingo_ans[2][i]:
    ans = "Yes"

if bingo_ans[0][0] and bingo_ans[1][1] and bingo_ans[2][2]:
  ans = "Yes"
  
if bingo_ans[2][0] and bingo_ans[1][1] and bingo_ans[0][2]:
  ans = "Yes"
  
print(ans)

Solution (Python):
a = []
for i in range(3):
    a1 = list(map(int,input().split()))
    a.append(a1)
l = [[0,0,0] for i in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                l[j][k] = 1
ans = "No"
naname1 = 0
naname2 = 0
for i in range(3):
    tate = 0
    yoko = 0
    for j in range(3):
        if l[i][j] == 1:
            tate += 1
        if l[j][i] == 1:
            yoko += 1
    if tate == 3 or yoko == 3:
        ans = "Yes"
    if l[i][i] == 1:
        naname1 += 1
    if l[2-i][i] == 1:
        naname2 += 1
if naname2 == 3 or naname1 == 3:
    ans = "Yes"
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

grid = [list(map(int, inp().split())) for _ in range(3)]
N = int(inp())
for _ in range(N):
  b = int(inpS())
  for i in range(3):
    for j in range(3):
      if grid[i][j] == b:
        grid[i][j] = -1
ans = "No"        
for i in range(3):
  if grid[i][0] == grid[i][1] == grid[i][2]: ans = "Yes"
  if grid[0][i] == grid[1][i] == grid[2][i]: ans = "Yes"
if grid[0][0] == grid[1][1] == grid[2][2]: ans = "Yes"
if grid[0][2] == grid[1][1] == grid[2][0]: ans = "Yes"
print(ans)

Solution (Python):
def isBingo(card):
    for x in range(3):
        if "".join(map(str,card[x]))=="ooo":return True
        if "".join([str(r[x]) for r in card])=="ooo":return True
    if card[0][0]==card[1][1]==card[2][2]:return True
    if card[0][2]==card[1][1]==card[2][0]:return True
    return False

def check(cardlist,numlist):
    for n in numlist:
        for row in range(3):
            for col in range(3):
                if cardlist[row][col]==n:cardlist[row][col]="o"
    return cardlist

a=[[int(i) for i in input().split()] for l in range(3)]
n=int(input())
m=[int(input()) for i in range(n)]
l=check(a,m)
if isBingo(l):print("Yes")
else:print("No")

Solution (Python):
def bng(card, nums):
    inv = {card[i][j]: (i,  j) for i in range(3) for j in range(3)}
    bingo  = {(i, j): False for i in range(3) for j in range(3)}
    for num in nums:
        if  inv.get(num) is not None:
            bingo[inv[num]] = True
    for i in range(3):
        if all(bingo[i, j] for j in range(3)) or all(bingo[j, i] for j in range(3)):
            return 'Yes'
    if all(bingo[i, i] for i in range(3)) or all(bingo[i, 2 - i] for i in range(3)):
        return 'Yes'
    return 'No'

card = [input().split() for _ in range(3)]
n = int(input())
nums = [input() for  _  in range(n)]
print(bng(card, nums))

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

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

for nu in range(len(s)):
	for i in range(3):
		for j in range(3):
			if a[i][j] == s[nu]:
				a[i][j] = 0
for r in range(3):
	if a[r][0]==a[r][1]==a[r][2]==0:
		print('Yes')
		exit()
	if a[0][r]==a[1][r]==a[2][r]==0:
		print('Yes')
		exit()

if a[0][0]==a[1][1]==a[2][2]==0	or a[0][2]==a[1][1]==a[2][0]==0:	
		print('Yes')
		exit() 
print('No')

Solution (Python):
row1 = list(map(int,input().split(" ")))
row2 = list(map(int,input().split(" ")))
row3 = list(map(int,input().split(" ")))

col1 = [row1[0],row2[0],row3[0]]
col2 = [row1[1],row2[1],row3[1]]
col3 = [row1[2],row2[2],row3[2]]

dig1 = [row1[0],row2[1],row3[2]]
dig2 =[row1[2],row2[1],row3[0]]

n = int(input())
res = []
for _ in range(n):
    res.append(int(input()))

if all([ele in res for ele in row1]) or all([ele in res for ele in row2]) or all([ele in res for ele in row3]) or all([ele in res for ele in col1]) or all([ele in res for ele in col2]) or all([ele in res for ele in col3]) or all([ele in res for ele in dig1]) or all([ele in res for ele in dig2]):
    print("Yes")
else:
    print("No")

Solution (Python):
card = []

for _ in range(3):
    card.extend(map(int, input().split(' ')))

jadge = [0] * 9
N = int(input())

for _ in range(N):
    n = int(input())
    if n in card:
        jadge[card.index(n)] = 1

bingo = False
for i in range(3):
    if (jadge[3 * i] + jadge[3 * i+1] + jadge[3 * i+2]) == 3:
        bingo = True
        break
    if (jadge[i] + jadge[3 + i] + jadge[6 + i]) == 3:
        bingo = True
        break
    if (jadge[i] + jadge[4] + jadge[8-i]) == 3:
        bingo = True
        break

if bingo:
    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()))
seat = [a1, a2, a3]
n = int(input())
b = [int(input()) for i in range(n)]

seat_tf = [[False, False, False] for _ in range(3)]

for k in b:
    for i in range(3):
        for j in range(3):
            if seat[i][j] == k:
                seat_tf[i][j] = True

for i in range(3):
    if seat_tf[i][0] and seat_tf[i][1] and seat_tf[i][2]:
        print("Yes")
        exit()

for j in range(3):
    if seat_tf[0][j] and seat_tf[1][j] and seat_tf[2][j]:
        print("Yes")
        exit()

if (seat_tf[0][0] and seat_tf[1][1] and seat_tf[2][2]) or (seat_tf[0][2] and seat_tf[1][1] and seat_tf[2][0]):
    print("Yes")
    exit()
print("No")

Solution (Python):
A = [list(map(int,input().split())) for i in range(3)]
A_flat=[]
for i in range(len(A)):
    A_flat.append(A[i][0])
    A_flat.append(A[i][1])
    A_flat.append(A[i][2])

N = int(input())
b = [int(input()) for i in range(N)]
for i in range(len(b)):
    if b[i] in A_flat:
        index = A_flat.index(b[i])
        A_flat[index] = 0

judge=False
for i in range(3):
    if A_flat[0+i] == A_flat[3+i] == A_flat[6+i]:
        print("Yes")
        judge = True
        break
    elif A_flat[0+i*3]==A_flat[1+i*3]==A_flat[2+i*3]:
        print("Yes")
        judge = True
        break
    elif A_flat[0]==A_flat[4]==A_flat[8] or A_flat[2]==A_flat[4]==A_flat[6]:
        print("Yes")
        judge = True
        break

if judge is False:
    print("No")

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j]=-1
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==-1:
        print('Yes')
        exit()
    if 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):
import sys
rl = sys.stdin.readline

rows = 3
cols = 3
a11,a12,a13 = [int(x) for x in rl().split(' ')]
a21,a22,a23 = [int(x) for x in rl().split(' ')]
a31,a32,a33 = [int(x) for x in rl().split(' ')]

n = int(rl())
b = []

for i in range(n):
    b.append(int(rl()))



card = [a11,a12,a13,a21,a22,a23,a31,a32,a33]

for num in b:
    for i in range(len(card)):
        if card[i] == num:
            card[i] = 0


def check(card):
    for y in range(rows):
        if all([card[y*rows+x] == 0 for x in range(cols)]):
            return True

    
    for x in range(cols):
        if all([card[y*rows+x] == 0 for y in range(rows)]):
            return True

    
    if all([card[xy*rows+xy] == 0 for xy in range(rows)]):
            return True

    if all([card[xy*rows+cols-1-xy] == 0 for xy in range(rows)]):
            return True

    return False


if check(card):
    print("Yes")
else:
    print("No")

Solution (Python):
a = []
for rep in range(3):
	a.append(list(map(int,input().split())))
n = int(input())
b = []
for rep in range(n):
    b.append(int(input()))
row = [0,0,0]
col = [0,0,0]
mid = 0
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            row[i] += 1
            col[j] += 1
            if i==1 and j==1:
                mid = 1
f = 1
for rep in range(3):
    if row[rep]==0 or col[rep]==0:
        f = 0
        break
if 3 in row or 3 in col:
    print("Yes")
elif f == 1 and mid == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
A = [[int(_) for _ in input().split()] for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]

for a in A:
    for b in B:
        if b in a:
            a[a.index(b)] = 0

ans = "No"
if [A[i][i] for i in range(3)] == [0, 0, 0]:
    ans = "Yes"
if [A[i][2-i] for i in range(3)] == [0, 0, 0]:
    ans = "Yes"
for i in range(3):
    if A[i] == [0, 0, 0]:
        ans = "Yes"
    if [A[j][i] for j in range(3)] == [0, 0, 0]:
        ans = "Yes"
print(ans)

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def main():
    
    A = LIR(3)
    N = I()
    B = IR(N)

    bingo_card = [[0, 0, 0] for i in range(3)]

    for b in B:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    bingo_card[i][j] = 1

    flag = 0

    for i in range(3):
        if sum(bingo_card[i]) == 3:
            flag = 1
            break

        if bingo_card[0][i] + bingo_card[1][i] + bingo_card[2][i] == 3:
            flag = 1
            break

    if sum([bingo_card[i][i] for i in range(3)]) == 3:
        flag = 1

    if sum([bingo_card[i][2 - i] for i in range(3)]) == 3:
        flag = 1

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

    return 0



if __name__ == "__main__":
    main()

Solution (Python):
a1 = [int(e) for e in input().split()]
a2 = [int(e) for e in input().split()]
a3 = [int(e) for e in input().split()]
n = int(input())
bs = []
for _ in range(n):
    bs.append(int(input()))

def is_bingo(mat,hits):
    row_pattern = [[mat[i][j] for j in range(3)] for i in range(3)]
    col_pattern = [[mat[j][i] for j in range(3)] for i in range(3)]
    cross_patten= [[mat[i][i] for i in range(3)] , [mat[0][2],mat[1][1],mat[2][0]]]
    if any([set(pattern).issubset(hits) for pattern in row_pattern+col_pattern+cross_patten]):
        return True
    return False
  
m=[a1,a2,a3]
print('Yes' if is_bingo(m,bs) else 'No')

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

ans = 'No'
for i in range(3):
    if a[i][0]+a[i][1]+a[i][2] == 0 or a[0][i]+a[1][i]+a[2][i] == 0:
        ans = 'Yes'
if a[0][0]+a[1][1]+a[2][2] == 0 or a[0][2]+a[1][1]+a[2][0] == 0:
    ans = 'Yes'

print(ans)

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

result = [[False, False, False], [False, False, False], [False, False, False]]
chk = 0
for r_idx, row in enumerate(table):
    for c_idx, col in enumerate(row):
        result[r_idx][c_idx] = col in p_list


for i in range(3):
    if result[i][0] and result[i][1] and result[i][2]:
        chk += 1
    if result[0][i] and result[1][i] and result[2][i]:
        chk += 1

if result[0][0] and result[1][1] and result[2][2]:
    chk += 1

if result[0][2] and result[1][1] and result[2][0]:
    chk += 1

print('Yes' if chk > 0 else '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)]
result=[[0]*3 for i in range(3)]
for i in range(3):
  for j in range(3):
    for k in range(n):
      if a[i][j]==b[k]:
        result[i][j]=1
for i in range(3):
  cnth=0
  cntw=0
  for j in range(3):
    cnth+=result[i][j]
    cntw+=result[j][i]
  if cnth==3 or cntw==3:
    print('Yes')
    exit()
if result[0][0]==result[1][1]==result[2][2]==1 or result[0][2]==result[1][1]==result[2][0]==1:
  print('Yes')
  exit()
print('No')

Solution (Python):
import sys

As = []
for i in range(3):
    tmp = list(map(int, input().split()))
    for j in range(3):
        As.append({'value': tmp[j], 'isMarked': False})


N = int(input())

for i in range(N):
    b = int(input())
    for Ai in As:
        if Ai['value'] == b:
            Ai['isMarked'] = True

bingo_list = [[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 bingo in bingo_list:
    if As[bingo[0]]['isMarked'] and As[bingo[1]]['isMarked'] and As[bingo[2]]['isMarked']:
        print('Yes')
        sys.exit(0)

print('No')

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

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

N = int(input())
B = list()
for _ in range(N):
    B.append(int(input()))

flag = [[False] * 3 for i in range(3)]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                flag[i][j] = True
                break

ans = False
for i in range(3):
    if flag[i].count(True) == 3:
        ans = True
    if [f[i] for f in flag].count(True) == 3:
        ans = True
if flag[0][0] == flag[1][1] == flag[2][2] == True or flag[0][2] == flag[1][1] == flag[2][0] == True:
    ans = True

print('Yes' if ans else 'No')

Solution (Python):
a = []
bingo = [[False for _ in range(3)] for __ in range(3)]
for _ in range(3):
  a.append(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]:
        bingo[j][k] = True
n_bingo = 0
for r in range(3):
  if bingo[r][0] and bingo[r][1] and bingo[r][2]:
    n_bingo += 1
for c in range(3):
  if bingo[0][c] and bingo[1][c] and bingo[2][c]:
    n_bingo += 1
if bingo[0][0] and bingo[1][1] and bingo[2][2]:
  n_bingo += 1
if bingo[0][2] and bingo[1][1] and bingo[2][0]:
  n_bingo += 1

if n_bingo > 0:
  print('Yes')
else:
  print('No')

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

n = int(input())

ans = "No"

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

for i in range(3):
	if a[i][0] == a[i][1] == a[i][2] == -1:ans = "Yes"
	if a[0][i] == a[1][i] == a[2][i] == -1:ans = "Yes"
if a[0][0] == a[1][1] == a[2][2] == -1:ans = "Yes"
if a[0][2] == a[1][1] == a[0][2] == -1:ans = "Yes"
print(ans)

Solution (Python):
import numpy as np

bingo = np.zeros([3,3])
check = np.zeros([3,3])
choice = []
flag = "No"

for i in range(3):
    a = input().split()
    a = [int(x) for x in a]
    bingo[i] = a
N = int(input())
for i in range(N):
    choice.append(int(input()))

convert = bingo.reshape([9])
for i in range(9):
    for j in choice:
        if(convert[i] == j):
            check[i//3][i%3] = 1
            continue

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

print(flag)

Solution (Python):
a=[]
for i in range(3):
    line=list(map(int,input().split()))
    a.append(line)
n=int(input())
b=[]
for i in range(n):
    b.append(int(input()))
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j]=0
bingo=0
for i in range(3):
    sum_=0
    for j in range(3):
        sum_+=a[i][j]
    if sum_==0:
        bingo+=1
for i in range(3):
    sum_=0
    for j in range(3):
        sum_+=a[j][i]
    if sum_==0:
        bingo+=1
if a[0][0]+a[1][1]+a[2][2]==0:
    bingo+=1
if a[0][2]+a[1][1]+a[2][0]==0:
    bingo+=1
print("Yes" if 0<bingo else "No")

Solution (Python):
import sys

def calc_flag(b,a,flag):
    if b in a:
        
        l_index = [i for i, x in enumerate(a) if x == b]
        for l in l_index:
            flag[l]=1
    return flag

a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())

flag1 = [0,0,0]
flag2 = [0,0,0]
flag3 = [0,0,0]

for i in range(n):
    b = int(input())
    flag1 = calc_flag(b,a1,flag1)
    flag2 = calc_flag(b,a2,flag2)
    flag3 = calc_flag(b,a3,flag3)



for i in range(3): 
    if flag1[i]+flag2[i]+flag3[i]==3:
        print('Yes')
        sys.exit()

if flag1[0]+flag2[1]+flag3[2]==3 or flag1[2]+flag2[1]+flag3[0]==3: 
    print('Yes')
elif sum(flag1)==3 or sum(flag2)==3 or sum(flag3)==3: 
    print('Yes')
else:
    print('No')

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

n = int(input())

for i in range(n):
    b = int(input())
    for j in range(9):
        if b == a[j]:
            a[j] = 'o'

isBingo = False
bingo = [[0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 4, 8], [2, 4, 6]]
for elem in bingo:
    if a[elem[0]] == 'o' and a[elem[1]] == 'o' and a[elem[2]] == 'o':
        isBingo = True
        break

print('Yes') if isBingo else print('No')

Solution (Python):

bingo = []
for i in range(3):
    line = input().split(" ")
    bingo.append(line)

numbers = []
N = int(input())
for j in range(N):
    number = int(input())
    numbers.append(number)


for i in range(3):
    for j in range(3):
        for k in range(N):
            if int(bingo[i][j]) == numbers[k]:
                bingo[i][j] = 101


if bingo[0][0] == bingo[0][1] == bingo[0][2]:
    print("Yes")
elif bingo[1][0] == bingo[1][1] == bingo[1][2]:
    print("Yes")
elif bingo[2][0] == bingo[2][1] == bingo[2][2]:
    print("Yes")
elif bingo[0][0] == bingo[1][0] == bingo[2][0]:
    print("Yes")
elif bingo[0][1] == bingo[1][1] == bingo[2][1]:
    print("Yes")
elif bingo[0][2] == bingo[1][2] == bingo[2][2]:
    print("Yes")
elif bingo[0][0] == bingo[1][1] == bingo[2][2]:
    print("Yes")
elif bingo[0][2] == bingo[1][1] == bingo[2][0]:
    print("Yes")

else:
    print("No")

Solution (Python):

a=[]
for i in range(3):
    a.append(list(map(int,input().split())))
n=int(input())
b=[int(input()) for i in range(n)]
appear=[[False]*3 for i in range(3)]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j]==b[k]:
                appear[i][j]=True
                break
ans="No"
for i in range(3):
    if appear[i][0]==appear[i][1]==appear[i][2]==True:
        ans="Yes"
    if appear[0][i]==appear[1][i]==appear[2][i]==True:
        ans="Yes"
if appear[0][0]==appear[1][1]==appear[2][2]==True:
    ans="Yes"
if appear[2][0]==appear[1][1]==appear[0][2]==True:
    ans="Yes"
print(ans)

Solution (Python):
import sys
card = [[int(x) for x in input().split(' ') ] for _ in range(3)]

patterns = []

patterns += [[card[i][j] for i in range(3)] for j in range(3)]
patterns += [[card[j][i] for i in range(3)] for j in range(3)]
patterns.append([card[i][i] for i in range(3)])
patterns.append([card[i][2-i] for i in range(3)] )

ok = False
N = int(input())
for _ in range(N):
    b = int(input())
    for pat in patterns:
        while b in pat:
            pat.remove(b)
            
for pat in patterns:
    if len(pat) == 0:
        print('Yes')
        sys.exit()

print('No')

Solution (Python):
mat=[list(map(int,input().split())) for i in range(3)]
N=int(input())
c=0
for n in range(N):
  b=int(input())
  for i in range(3):
    for j in range(3):
      if mat[i][j]==b:
        mat[i][j]=0
for i in range(3):
  if mat[i][0]==0 and mat[i][1]==0 and mat[i][2]==0:
    c+=1
  elif mat[0][i]==0 and mat[1][i]==0 and mat[2][i]==0:
    c+=1
  elif mat[0][0]==0 and mat[1][1]==0 and mat[2][2]==0:
    c+=1
  elif mat[0][2]==0 and mat[1][1]==0 and mat[2][0]==0:
    c+=1

if c >= 1:
  print("Yes")
else:
  print("No")

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

for _ in range(n):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j]==b:
                g[i][j]=1

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

Solution (Python):
def bingo_search(CARD):
    for i in range(3):
        
        if CARD[i][0] == '☓' and CARD[i][1] == '☓' and CARD[i][2] == '☓':
            return True

    for j in range(3):
        
        if CARD[0][j] == '☓' and CARD[1][j] == '☓' and CARD[2][j] == '☓':
            return True

    
    if CARD[0][0] == '☓' and CARD[1][1] == '☓' and CARD[2][2] == '☓':
            return True

    
    if CARD[0][2] == '☓' and CARD[1][1] == '☓' and CARD[2][0] == '☓':
            return True

    return False



A1 = list(input().split())
A2 = list(input().split())
A3 = list(input().split())
A = [A1, A2, A3]  


N = int(input())
for i in range(N):
    flag = False
    b = input()
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = '☓'
                flag = True
                break
        if flag == True:
            break


if bingo_search(A):
    print("Yes")

else:
    print("No")

Solution (Python):
A1 = input().split()
A2 = input().split()
A3 = input().split()

hit_example = [7,56,73,84,146,273,292,448]
b = 0
ans = "No"

N = int(input())
for i in range(N):
  x = int(input())
  if int(A1[0]) == x:
    b += 256
  elif int(A1[1]) == x:
    b += 128
  elif int(A1[2]) == x:
    b += 64
  elif int(A2[0]) == x:
    b += 32
  elif int(A2[1]) == x:
    b += 16
  elif int(A2[2]) == x:
    b += 8
  elif int(A3[0]) == x:
    b += 4
  elif int(A3[1]) == x:
    b += 2
  elif int(A3[2]) == x:
    b += 1

for val in hit_example:
  if val & b == val:
    ans = "Yes"
    break
    
print(ans)

Solution (Python):
A1 = [int(x) for x in input().rstrip().split()]
A2 = [int(x) for x in input().rstrip().split()]
A3 = [int(x) for x in input().rstrip().split()]

for i in A2:
    A1.append(i)

for l in A3:
    A1.append(l)

N = int(input())

def my_index(l,a,default = False):
    if a in l:
        return l.index(a)
    else:
        return default

for i in range(N):
    a=int(input())
    for j in range(9):
        if a==A1[j]:
            A1[j]=0

        
            
 
if A1[0]==A1[1]==A1[2]==0:
    print("Yes")
elif A1[3]==A1[4]==A1[5]==0:
    print("Yes")
elif A1[6]==A1[7]==A1[8]==0:
    print("Yes")
elif A1[0]==A1[3]==A1[6]==0:
    print("Yes")
elif A1[1]==A1[4]==A1[7]==0:
    print("Yes")
elif A1[2]==A1[5]==A1[8]==0:
    print("Yes")
elif A1[0]==A1[4]==A1[8]==0:
    print("Yes")
elif A1[2]==A1[4]==A1[6]==0:
    print("Yes")
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)]
count=0
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j]=0
for i in range(3):
    if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
        count += 1
    elif a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
        count += 1

if a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
    count +=1
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
    count +=1

if count>0:
    print("Yes")
else:
    print("No")

Solution (Python):
A = []
for i in range(3):
  a = input().split()
  a = [int(num) for num in a]
  A.append(a)

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

for i in range(3):
  for j in range(3):
    if b.count(A[i][j]) != 0:
      A[i][j] = 0
    else:
      continue

def Agetraw(j):
    Ans = [int(A[i][j]) for i in range(3)]
    return(Ans)

if (sum(A[0])==0 or sum(A[1])==0 or sum(A[2])==0 
    or sum(Agetraw(0))==0 or sum(Agetraw(1))==0 or sum(Agetraw(2))==0 
    or A[0][0]+A[1][1]+A[2][2]==0 or A[0][2]+A[1][1]+A[2][0]==0):
  print("Yes")
else:
  print("No")

Solution (Python):
A = []
for i in range(3):
  a = input().split()
  a = [int(num) for num in a]
  A.append(a)

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

for i in range(3):
  for j in range(3):
    if b.count(A[i][j]) != 0:
      A[i][j] = 0
    else:
      continue

def Agetraw(j):
    Ans = [int(A[i][j]) for i in range(3)]
    return(Ans)

if (sum(A[0])==0 or sum(A[1])==0 or sum(A[2])==0 
    or sum(Agetraw(0))==0 or sum(Agetraw(1))==0 or sum(Agetraw(2))==0 
    or A[0][0]+A[1][1]+A[2][2]==0 or A[0][2]+A[1][1]+A[2][0]==0):
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
  a = []
  ans = "No"
  hit_examples = [[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 i in range(3):
    a.extend(list(map(int, input().split())))
  n = int(input())
  b = []
  for i in range(n):
    b.append(int(input()))
  for b_value in b:
    for i in range(len(a)):
      if b_value == a[i]:
        a[i] = -1

  for hit_example in hit_examples:
    cnt = 0
    for i in range(len(a)):
      if a[i] == -1 and i in hit_example:
        cnt += 1
      if cnt == 3:
        ans = "Yes"
        print(ans)
        return
  print(ans)

if __name__ == '__main__':
  main()

Solution (Python):
li = []
b = []
cl = [[0]*3]*3
for i in range(3):
    l = list(map(int,input().split()))
    li.append(l)
N = int(input())
for i in range(N):
    b.append(int(input()))
ii = [0]*3
kk = [0]*3
for i in range(3):
    for k in range(3):
        if li[i][k] in b:
            ii[i] += 1
            kk[k] += 1
if (3 in ii) or (3 in kk):
    print("Yes")
elif ((li[0][0] in b) and(li[1][1] in b) and(li[2][2] in b)) or ((li[0][2] in b) and (li[1][1] in b) and (li[2][0] in b) ):
    print("Yes")
else:
    print("No")

Solution (Python):
t = [0] * 3
x = [0] * 3
y = [0] * 3
a=[]
for i in range(3):
    t[i], x[i], y[i] = map(int, input().split())
a.append(t)
a.append(x)
a.append(y)
n=int(input())
li=[input() for i in range(n)]

ctr=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if int(a[i][j])==int(li[k]):
                ctr[i][j]+=1
if ctr[0][0]==ctr[0][1]==ctr[0][2]==1:
    print('Yes')
elif ctr[1][0]==ctr[1][1]==ctr[1][2]==1:
    print('Yes')
elif ctr[2][0]==ctr[2][1]==ctr[2][2]==1:
    print('Yes')
elif ctr[0][0]==ctr[1][0]==ctr[2][0]==1:
    print('Yes')
elif ctr[0][1]==ctr[1][1]==ctr[2][1]==1:
    print('Yes')
elif ctr[0][2]==ctr[1][2]==ctr[2][2]==1:
    print('Yes')
elif ctr[0][0]==ctr[1][1]==ctr[2][2]==1:
    print('Yes')
elif ctr[0][2]==ctr[1][1]==ctr[2][0]==1:
    print('Yes')
else:
    print('No')

Solution (Python):
def solve(A, n, b):
    for x in b:
        for i in range(3):
            for j in range(3):
                if A[i][j] == x:
                    A[i][j] = -1
    for i in range(3):
        ok = True
        for j in range(3):
            if A[i][j] != -1:
                ok = False
                break
        if ok:
            return "Yes"
    for j in range(3):
        ok = True
        for i in range(3):
            if A[i][j] != -1:
                ok = False
                break
        if ok:
            return "Yes"
    ok = True
    for i in range(3):
        if A[i][i] != -1:
            ok = False
    if ok:
        return "Yes"
    ok = True
    for i in range(3):
        if A[2-i][i] != -1:
            ok = False
    if ok:
        return "Yes"
    return "No"

A = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
print(solve(A, n, b))

Solution (Python):
a=[]
for i in range(3):
  a.append(list(map(int,input().split())))
n=int(input())
b=[[0,0,0],[0,0,0],[0,0,0]]
for j in range(n):
  x=int(input())
  for k in range(3):
    for l in range(3):
      if x==a[k][l]:
        b[k][l]=1
if b[0]==[1,1,1] or b[1]==[1,1,1] or b[2]==[1,1,1] or [b[0][0],b[1][0],b[2][0]]==[1,1,1] or [b[0][1],b[1][1],b[2][1]]==[1,1,1] or [b[0][2],b[1][2],b[2][2]]==[1,1,1] or [b[0][0],b[1][1],b[2][2]]==[1,1,1] or [b[0][2],b[1][1],b[2][0]]==[1,1,1]:
  print('Yes')
else:
  print('No')

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

bingo = False
for i in range(3):
    bingo = bingo or (A[i][0] in B and A[i][1] in B and A[i][2] in B)
    bingo = bingo or (A[0][i] in B and A[1][i] in B and A[2][i] in B)
bingo = bingo or (A[0][0] in B and A[1][1] in B and A[2][2] in B)
bingo = bingo or (A[0][2] in B and A[1][1] in B and A[2][0] in B)
print("Yes" if bingo else "No")