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 = []
for i in range(3):
    a.append(list(map(int,input().split())))
N=int(input())
b = [int(input()) for i in range(N)]
c=[[0,0,0],[0,0,0],[0,0,0]]
if a[0][0] in b:
    c[0][0]=1
if a[0][1] in b:
    c[0][1]=1
if a[0][2] in b:
    c[0][2]=1
if a[1][0] in b:
    c[1][0]=1
if a[1][1] in b:
    c[1][1]=1
if a[1][2] in b:
    c[1][2]=1
if a[2][0] in b:
    c[2][0]=1
if a[2][1] in b:
    c[2][1]=1
if a[2][2] in b:
    c[2][2]=1

if c[0][0]+c[0][1]+c[0][2]==3 or c[1][0]+c[1][1]+c[1][2]==3 or c[2][0]+c[2][1]+c[2][2]==3:
    print("Yes")
elif  c[0][0]+c[1][0]+c[2][0]==3 or c[0][1]+c[1][1]+c[2][1]==3 or c[0][2]+c[1][2]+c[2][2]==3:
    print("Yes")
elif c[0][0]+c[1][1]+c[2][2]==3 or c[0][2]+c[1][1]+c[2][0]==3:
    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)]

ans = [["_" for _ in range(3)] for _ in range(3)]
bingo = False

for i in b:
  for j in range(3):
    for k in range(3):
      if i == A[j][k]:
        ans[j][k] = "〇"
        
for i in range(3):        
  if ans[i][0] == ans[i][1] == ans[i][2] == "〇":
    bingo = True
  if ans[0][i] == ans[1][i] == ans[2][i] == "〇":
    bingo = True

if ans[0][0] == ans[1][1] == ans[2][2] == "〇":
  bingo = True
if ans[0][2] == ans[1][1] == ans[2][0] == "〇":
  bingo = True
  
if bingo:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys

A = list(map(int, input().split()))
A1 =  list(map(int, input().split()))
A2 =  list(map(int, input().split()))

bingo_lis = A + A1 + A2




N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))  


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


for i in range(len(lis)):
    tmp_lis = lis[i]
    ans = 0
    for j in tmp_lis:
        if bingo_lis[j] in b:
            ans = ans + 1
    if ans == 3:
        print("Yes")
        sys.exit()
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())
b = [int(input()) for i in range(n)]

for i in b:
    for j in range(3):
        if i == a1[j]:
            a1[j] = "x"
        if i == a2[j]:
            a2[j] = "x"
        if i == a3[j]:
            a3[j] = "x"
            
if a1.count("x") == 3 or a2.count("x") == 3 or a3.count("x") == 3:
    print("Yes")
elif a1[0] == "x" and a2[0] == "x" and a3[0] == "x":
    print("Yes")
elif a1[1] == "x" and a2[1] == "x" and a3[1] == "x":
    print("Yes")
elif a1[2] == "x" and a2[2] == "x" and a3[2] == "x":
    print("Yes")
elif a1[0] == "x" and a2[1] == "x" and a3[2] == "x":
    print("Yes")
elif a1[2] == "x" and a2[1] == "x" and a3[0] == "x":
    print("Yes")
else:
    print("No")

Solution (Python):
A = []
for _ in range(3):
  A += list(map(int,input().split()))
n = int(input())
ans = [0]*9
for _ in range(n):
  b = int(input())
  if b in A:
    i = A.index(b)
    if i != -1:
      ans[i] = 1
bingo = [0b111000000,0b000111000,0b000000111,0b100100100,0b010010010,0b001001001,0b100010001,0b001010100]
f = 0
sheet = 0
for i in range(9):
  sheet += ans[i] * 2 ** (8 - i)
for i in range(8):
  ansb = sheet & bingo[i]
  if (ansb & bingo[i]) in bingo:
    f = 1
    break
if f == 1:
  print('Yes')
else:
  print('No')

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


if a[0][0] in b and a[0][1] in b and a[0][2] in b:
    print("Yes")
    exit()
elif a[1][0] in b and a[1][1] in b and a[1][2] in b:
    print("Yes")
    exit()
elif a[2][0] in b and a[2][1] in b and a[2][2] in b:
    print("Yes")
    exit()
elif a[0][0] in b and a[1][0] in b and a[2][0] in b:
    print("Yes")
    exit()
elif a[0][1] in b and a[1][1] in b and a[2][1] in b:
    print("Yes")
    exit()
elif a[0][2] in b and a[1][2] in b and a[2][2] in b:
    print("Yes")
    exit()
elif a[0][0] in b and a[1][1] in b and a[2][2] in b:
    print("Yes")
    exit()
elif a[2][0] in b and a[1][1] in b and a[0][2] in b:
    print("Yes")
    exit()
else:
    print("No")

Solution (Python):

def read_input():
    cards = []
    for i in range(3):
        r = list(map(int, input().split()))
        cards.append(r)

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

    return cards, blist


def get_row(cards, i):
    return cards[i]


def get_col(cards, i):
    col = [cards[j][i] for j in range(3)]
    return col


def get_diag(cards):
    diag = [cards[i][i] for i in range(3)]
    return diag


def get_re_diag(cards):
    diag = [cards[i][2 - i] for i in range(3)]
    return diag


def submit():
    cards, blist = read_input()

    numbers = set(blist)
    bingo = False
    for i in range(3):
        r = get_row(cards, i)
        if set(r) <= numbers:
            print("Yes")
            return

        c = get_col(cards, i)
        if set(c) <= numbers:
            print("Yes")
            return

    if set(get_diag(cards)) <= numbers:
        print("Yes")
        return

    if set(get_re_diag(cards)) <= numbers:
        print("Yes")
        return

    print("No")


if __name__ == "__main__":
    submit()

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

n = int(input())

ans = []
for _ in range(3):
  ans += [0]*3
  
for _ in range(n):
  b = int(input())
  if b in a:
    ans[a.index(b)] = 1
    
f = False
for i in range(3):
  if sum(ans[3*i:3*i+3]) == 3:
    f = True

for i in range(3):
  if sum(ans[i::3]) == 3:
    f = True
    
if (ans[0] + ans[4] + ans[8]) == 3:
  f = True
if (ans[2] + ans[4] + ans[6]) == 3:
  f = True
  
if f:
  print('Yes')
else:
  print('No')

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

if ((a[0]==a[1]==a[2]==0) or (a[3]==a[4]==a[5]==0) or (a[6]==a[7]==a[8]==0)):
    print('Yes')
elif ((a[0]==a[3]==a[6]==0) or (a[1]==a[4]==a[7]==0) or (a[2]==a[5]==a[8]==0)):
    print('Yes')
elif ((a[0]==a[4]==a[8]) or (a[2]==a[4]==a[6])):
    print('Yes')
else:
    print('No')

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

N = int(input())

B = []
for i in range(N):
    B.append(int(input()))

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

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

Solution (Python):
A = [0]*3
for i in range(0,3):
    A[i] = list(map(int, input().split()))
N = int(input())
b = [int(input()) for i in range(N)]
 
count = 0
while count < N:
    for i in range(0,3):
      for j in range(0,3):
        if b[count] == A[i][j]:
          A[i][j] = 0
    count += 1
            

sum_y = [0]*3                
for i in range(0,3):
  for j in range(0,3):
    sum_y[i] += A[i][j]
 
sum_t = [0]*3
for i in range(0,3):
  for j in range(0,3):
    sum_t[i] += A[j][i]
    
 
sum1 = A[0][0] + A[1][1] + A[2][2]
sum2 = A[0][2] + A[1][1] + A[0][2]
 
if sum_y[0] == 0:
    print("Yes")
elif sum_y[1] == 0:
    print("Yes")
elif sum_y[2] == 0:
    print("Yes")
elif sum_t[0] == 0:
    print("Yes") 
elif sum_t[1] == 0:
    print("Yes") 
elif sum_t[2] == 0:
    print("Yes") 
elif sum1 == 0:
  print("Yes")
elif sum2 == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def main():
    A_1 = list(map(int,input().split()))
    A_2 = list(map(int,input().split()))
    A_3 = list(map(int,input().split()))

    A = [A_1,A_2,A_3]
    N = int(input())
    bingo = [[0] * 4 for _ in range(4)]
    for _ in range(N):
        b = int(input())

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


    for i in range(4):
        if bingo[i][0] == bingo[i][1] == bingo[i][2] == 1:
            print("Yes")
            exit()
        elif bingo[0][i] == bingo[1][i] == bingo[2][i] == 1:
            print("Yes")
            exit()


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

    print("No")



if __name__ == "__main__":
  main()

Solution (Python):
list_row1= list(map(int, input().split()))
list_row2= list(map(int, input().split()))
list_row3= list(map(int, input().split()))
N = int(input())
list_b = []
for i in range(N):
    list_b.append(int(input()))
list_col1 = [list_row1[0], list_row2[0], list_row3[0]]
list_col2 = [list_row1[1], list_row2[1], list_row3[1]]
list_col3 = [list_row1[2], list_row2[2], list_row3[2]]
list_sla1 = [list_row1[0], list_row2[1], list_row3[2]]
list_sla2 = [list_row1[2], list_row2[1], list_row3[0]]
bingo_list = [list_row1, list_row2, list_row3, list_col1, list_col2, list_col3, list_sla1, list_sla2]
for lists in bingo_list:
    cnt = 0
    for i in range(3):
        if lists[i] in list_b:
            cnt += 1
    if cnt == 3:
        print("Yes")
        break
else:
    print("No")

Solution (Python):
A=[]
m=[[0,0,0],[0,0,0],[0,0,0]]

for i in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
def add(n):
    for i in range(3):
        if n in A[i]:
            m[i][A[i].index(n)]=1

def check():
    for i in m:
        if i == [1,1,1]:
            return True
    for i in range(3):
        if m[0][i]+m[1][i]+m[2][i]==3:
            return True
    if m[0][0]+m[1][1]+m[2][2]==3:
        return True
    if m[2][0]+m[1][1]+m[0][2]==3:
        return True
    return False

for i in range(N):
    inp=int(input())
    add(inp)
    if check():
        print("Yes")
        exit()
print("No")

Solution (Python):
import numpy as np

a = [input().split() for l in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
bingo = 0
wa = 0

a = np.array(a)

i = 0
while i < N:
    for j in range(3):
        for h in range(3):
            if int(a[j,h]) == int(b[i]):
                a[j,h] = 0
    i = i + 1

for j in range(3):
    wa = a[j,0] + a[j,1] + a[j,2]
    if int(wa) == 0:
        bingo = 1

for h in range(3):
    wa = a[0,h] + a[1,h] + a[2,h]
    if int(wa) == 0:
        bingo = 1

if int(a[0,0]+a[1,1]+a[2,2]) == 0:
    bingo = 1

if int(a[0,2]+a[1,1]+a[2,0]) == 0:
    bingo = 1
    
if bingo == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np

card = np.array([list(map(int, input().split())) for _ in range(3)])
bingo = np.zeros([3, 3])

n = int(input())
for _ in range(n):
    b = int(input())
    bingo[card == b] = 1

if np.any(np.all(bingo == 1, axis=1)):
    print('Yes')
elif np.any(np.all(bingo == 1, axis=0)):
    print('Yes')
elif (bingo[0, 0] == 1 and bingo[1, 1] == 1 and bingo[2, 2] == 1) or \
      (bingo[0, 2] == 1 and bingo[1, 1] == 1 and bingo[2, 0] == 1):
    print('Yes')
else:
    print('No')

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

n = int(input())

for i in range(n):
  num = int(input())
  if num in bingo:
    bingo = [str(bingo[i]) for i in range(len(bingo))]
    bingo[bingo.index(str(num))] = 0
    bingo = [int(bingo[i]) for i in range(len(bingo))]

ans1 = bingo[0]+bingo[1]+bingo[2] 
ans2 = bingo[3]+bingo[4]+bingo[5]
ans3 = bingo[6]+bingo[7]+bingo[8]
ans4 = bingo[0]+bingo[3]+bingo[6]
ans5 = bingo[1]+bingo[4]+bingo[7]
ans6 = bingo[2]+bingo[5]+bingo[8]
ans7 = bingo[0]+bingo[4]+bingo[8]
ans8 = bingo[2]+bingo[4]+bingo[6]

if ans1==0 or ans2==0 or ans3==0 or ans4==0 or ans5==0 or ans6==0 or ans7==0 or ans8==0:
  print('Yes')
else:
  print('No')

Solution (Python):

"""
Created on Fri Jan 24 14:37:00 2020

@author: matsui
"""
import numpy as np
bingo=np.zeros([3,3])
result=np.zeros([3,3])
A=input().split()
bingo[0,0]=int(A[0])
bingo[0,1]=int(A[1])
bingo[0,2]=int(A[2])
A=input().split()
bingo[1,0]=int(A[0])
bingo[1,1]=int(A[1])
bingo[1,2]=int(A[2])
A=input().split()
bingo[2,0]=int(A[0])
bingo[2,1]=int(A[1])
bingo[2,2]=int(A[2])

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

ans='No'
if result[0,0]==1 and result[0,1]==1 and result[0,2]==1: ans='Yes'
if result[1,0]==1 and result[1,1]==1 and result[1,2]==1: ans='Yes'
if result[2,0]==1 and result[2,1]==1 and result[2,2]==1: ans='Yes'

if result[0,0]==1 and result[1,0]==1 and result[2,0]==1: ans='Yes'
if result[0,1]==1 and result[1,1]==1 and result[2,1]==1: ans='Yes'
if result[0,2]==1 and result[1,2]==1 and result[2,2]==1: ans='Yes'

if result[0,0]==1 and result[1,1]==1 and result[2,2]==1: ans='Yes'
if result[0,2]==1 and result[1,1]==1 and result[2,0]==1: ans='Yes'

print(ans)

Solution (Python):
import numpy as np

l = []
for _ in range(3):
    l.append(list(map(int, input().split())))
l = np.array(l)

n = int(input())

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

ans = np.zeros((3,3))

for i in range(n):
    ans += np.where(l == li[i], 1, 0)

count = 0
c = 1
for i in range(3):
    c *= ans[i,0]
count += c
c = 1

for i in range(3):
    c *= ans[i,1]
count += c
c = 1

for i in range(3):
    c *= ans[i,2]
count += c
c = 1

for i in range(3):
    c *= ans[0,i]
count += c
c = 1

for i in range(3):
    c *= ans[1,i]
count += c
c = 1

for i in range(3):
    c *= ans[2,i]
count += c
c = 1

for i in range(3):
    c *= ans[i,0]
count += c
c = 1

for i in range(3):
    c *= ans[i,i]
count += c
c = 1

for i in range(3):
    c *= ans[i,2-i]
count += c

if count != 0:
    print("Yes")
else:
    print('No')

Solution (Python):
import numpy as np
from sys import stdin


def get_result(data):
    A = np.array([data[0], data[1], data[2]])
    N = data[3][0]
    B = [data[i+4][0] for i in range(N)]
    for i in range(3):
        for j in range(3):
            if A[i, j] in B:
                A[i, j] = 1
            else:
                A[i, j] = 0
    
    tmp = []
    for i in range(3):
        tmp.append(sum(A[:, i]))
        tmp.append(sum(A[i, :]))
    tmp.append(A[0,0]+ A[1,1]+A[2,2])
    tmp.append(A[0,2]+ A[1,1]+A[2,0])
    return 'Yes' if 3.0 in tmp else 'No'

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

Solution (Python):
A=[]
for i in range(0,3):
    k=list(map(int,input().split(' ')))
    A.append(k)
n=int(input())
b=[]
for i in range(0,n):
    b.append(int(input()))
for i in range(0,3):
    if (A[1][i] in b and A[2][i] in b and A[0][i] in b):
        print('Yes')
        quit()
    if (A[i][1] in b and A[i][2] in b and A[i][0] in b):
        print('Yes')
        quit()
if (A[0][0] in b and A[2][2] in b and A[1][1] in b):
    print('Yes')
    quit()
if (A[0][2] in b and A[2][0] in b and A[1][1] in b):
    print('Yes')
    quit()
print('No')

Solution (Python):
import sys

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

ans = [[0,0,0], [0,0,0], [0,0,0]]
for l in line:
    for i in range(3):
        for j in range(3):
            if l == bing[i][j]:
                ans[i][j] = bing[i][j]


for l in ans:
    if 0 not in l:
        print("Yes")
        sys.exit()


for i in range(3):
    if ans[0][i] != 0 and ans[1][i] != 0 and ans[2][i] != 0:
        print("Yes")
        sys.exit()


if ans[0][0] != 0 and ans[1][1] != 0 and ans[2][2] != 0:
    print("Yes")
elif ans[0][2] != 0 and ans[1][1] != 0 and ans[2][0] != 0:
    print("Yes")
else:
    print("No")

Solution (Python):
a = []
a.append(list(input().split()))
a.append(list(input().split()))
a.append(list(input().split()))
flag = [[False]*3]*3

n = int(input())

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

ans = 'No'

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

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

if (a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0):
  ans = 'Yes'
elif (a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0):
  ans = 'Yes'

print(ans)

Solution (Python):
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 b:
    for j in range(3):
        for k in range(3):
            if a[j][k] == i:
                a[j][k] = 0

tmp = 0
if a[0][0] + a[1][1] + a[2][2] == 0:
    tmp = 1
if a[0][2] + a[1][1] + a[2][0] == 0:
    tmp = 1
if a[0][0] + a[0][1] + a[0][2] == 0:
    tmp = 1
if a[1][0] + a[1][1] + a[1][2] == 0:
    tmp = 1
if a[2][0] + a[2][1] + a[2][2] == 0:
    tmp = 1
if a[0][0] + a[1][0] + a[2][0] == 0:
    tmp = 1
if a[0][1] + a[1][1] + a[2][1] == 0:
    tmp = 1
if a[0][2] + a[1][2] + a[2][2] == 0:
    tmp = 1

if tmp == 1:
    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())
B = [int(input()) for _ in range(N)]

for b in B:
    for i in range(3):
        if b == A1[i]:
            A1[i] = 0
        if b == A2[i]:
            A2[i] = 0
        if b == A3[i]:
            A3[i] = 0


if ((A1[0] == 0 and A2[0] == 0 and A3[0] == 0) or
    (A1[1] == 0 and A2[1] == 0  and A3[1] == 0) or
    (A1[2] == 0 and A2[2] == 0  and A3[2] == 0) or
    (A1[0] == 0 and A1[1] == 0  and A1[2] == 0) or
    (A2[0] == 0 and A2[1] == 0  and A2[2] == 0) or
    (A3[0] == 0 and A3[1] == 0  and A3[2] == 0) or
    (A1[0] == 0 and A2[1] == 0  and A3[2] == 0) or
    (A1[2] == 0 and A2[1] == 0  and A3[0] == 0)):
    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())
s = [int(input()) for i in range(N)]

Alist = A1+A2+A3
A = [0]*len(Alist)

for i in range(len(Alist)):
    if s.count(Alist[i])>0:
        A[i]=1

if A[0]+A[1]+A[2]>2 or A[3]+A[4]+A[5]>2 or A[6]+A[7]+A[8]>2 or A[0]+A[3]+A[6]>2 or A[1]+A[4]+A[7]>2 or A[2]+A[5]+A[8]>2 or A[0]+A[4]+A[8]>2 or A[2]+A[4]+A[6]>2:
    print("Yes")
else:
    print("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):
    b.append(int(input()))

a2 = []
a3 = []

for i in range(3):
    a2.append([a[0][i], a[1][i], a[2][i]])

a3.append([a[0][0], a[1][1], a[2][2]])
a3.append([a[0][2], a[1][1], a[2][0]])

for i in range(3):
    for _b in b:
        if _b in a[i]:
            a[i].remove(_b)

for i in range(3):
    if len(a[i]) == 0:
        print("Yes")
        exit()

for i in range(3):
    for _b in b:
        if _b in a2[i]:
            a2[i].remove(_b)

for i in range(3):
    if len(a2[i]) == 0:
        print("Yes")
        exit()

for i in range(2):
    for _b in b:
        if _b in a3[i]:
            a3[i].remove(_b)

for i in range(2):
    if len(a3[i]) == 0:
        print("Yes")
        exit()

print("No")

Solution (Python):
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
N=int(input())
for i in range(N):
  b = int(input())
  for k in range(3):
    if A[k]==b:
      A[k]=0
    if B[k]==b:
      B[k]=0
    if C[k]==b:
      C[k]=0 
if (A[0]==A[1]==A[2]) or (B[0]==B[1]==B[2]) or (C[0]==C[1]==C[2]) or (A[0]==B[0]==C[0]) or (A[1]==B[1]==C[1]) or (A[2]==B[2]==C[2]) or(A[0]==B[1]==C[2]) or (A[2]==B[1]==C[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)]
ans = "No"

for i in b:
    for num, j in enumerate(a):
        if i in j:
            a[num][a[num].index(i)] = True
tmp = []
for i in a:
    tmp.extend(i)

tmp2 = []
for i, num in enumerate(tmp):
    if num is True:
        tmp2.append(i + 1)

ans_arr = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
    [1, 4, 7],
    [2, 5, 8],
    [3, 6, 9],
    [1, 5, 9],
    [3, 5, 7],
]
for i in ans_arr:
    count = 0
    for j in tmp2:
        if j not in i:
            pass
        else:
            count += 1
    if count == 3:
        ans = "Yes"
        break

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())
bs = [int(input()) for _ in range(0, N)]

ans1 = [0, 0, 0]
ans2 = [0, 0, 0]
ans3 = [0, 0, 0]

def bingo_column():
    return ans1 == [1,1,1] or ans2 == [1,1,1] or ans3 == [1,1,1]

def bingo_row():
    if ans1[0] == 1 and ans2[0] == 1 and ans3[0] == 1:
        return True
    if ans1[1] == 1 and ans2[1] == 1 and ans3[1] == 1:
        return True
    if ans1[2] == 1 and ans2[2] == 1 and ans3[2] == 1:
        return True
    
    return False

def bingo_naname():
    if ans1[0] == 1 and ans2[1] == 1 and ans3[2] == 1:
        return True
    if ans1[2] == 1 and ans2[1] == 1 and ans3[0] == 1:
        return True
    return False

bingo = False
for b in bs:
    if b in A1:
        ix = A1.index(b)
        ans1[ix] = 1
    if b in A2:
        ix = A2.index(b)
        ans2[ix] = 1
    if b in A3:
        ix = A3.index(b)
        ans3[ix] = 1

    if bingo_column():
        bingo = True
    if bingo_row():
        bingo = True
    if bingo_naname():
        bingo = True

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

Solution (Python):
L1 = [int(x) for x in input().split()]
L2 = [int(x) for x in input().split()]
L3 = [int(x) for x in input().split()] 
AL = L1 + L2 + L3
N = int(input())
for x in range(N):
    IN = int(input())
    if IN in AL:
        AL[AL.index(IN)] = 0
for x in range(3):
    if AL[0+x] == AL[3+x] == AL[6+x] == 0:
        print("Yes")
        exit()
if AL[0] == AL[4] == AL[8] == 0:
    print("Yes")
    exit()
elif AL[2] == AL[4] == AL[6] == 0:
    print("Yes")
    exit()
elif AL[0] == AL[1] == AL[2] == 0:
    print("Yes")
    exit()
elif AL[3] == AL[4] == AL[5] == 0:
    print("Yes")
    exit()
elif AL[6] == AL[7] == AL[8] == 0:
    print("Yes")
    exit()
print("No")

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

for i in range(N):
    b = int(input())
    for I in range(3):
        for J in range(3):
            if A[I][J] == b:
                A[I][J] = 0

bingo = False





for i in range(3):
    
    if A[i][:] == [0, 0, 0]:
        bingo = True


for j in range(3):
    
    if [A[0][j], A[1][j], A[2][j]] == [0, 0, 0]:
        bingo = True




if [A[0][0], A[1][1], A[2][2]] == [0, 0, 0]:
    bingo = True



if [A[0][2], A[1][1], A[2][0]] == [0, 0, 0]:
    bingo = True

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

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

for i in range(3):
    if all([a in b for a in A[i]]):
        flag = True

if not flag:
    for j in range(3):
        tmp = [A[0][j], A[1][j], A[2][j]]
        if all([a in b for a in tmp]):
            flag = True

if not flag:
    tmp = [A[0][0], A[1][1], A[2][2]]
    if all([a in b for a in tmp]):
        flag = True

if not flag:
    tmp = [A[0][2], A[1][1], A[2][0]]
    if all([a in b for a in tmp]):
        flag = True

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

Solution (Python):
def cal(lst1, lst2):
    lst3 = [0, 0, 0]
    for i in range(3):
        if lst1[i] in lst2:
            lst3[i] = 1
    return lst3

def judge(a, b, c):
    if (a == 1) and (a == b == c):
        return True
    else:
        return False

A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]

C_1 = []
C_2 = []
C_3 = []

C_1 = cal(A_1, b)
C_2 = cal(A_2, b)
C_3 = cal(A_3, b)

a = judge(C_1[0], C_2[0], C_3[0])
b = judge(C_1[1], C_2[1], C_3[1])
c = judge(C_1[2], C_2[2], C_3[2])

d = judge(C_1[0], C_1[1], C_1[2])
e = judge(C_2[0], C_2[1], C_2[2])
f = judge(C_3[0], C_3[1], C_3[2])

g = judge(C_1[0], C_2[1], C_3[2])
h = judge(C_1[2], C_2[1], C_3[0])

lst = [a, b, c, d, e, f, g, h]

if True in lst:
    print('Yes')
else:
    print('No')

Solution (Python):
def isBingo(input):
  for i in range(3):
    if input[i][0] is None and input[i][1] is None and input[i][2] is None:
      return True
  for i in range(3):
    if input[0][i] is None and input[1][i] is None and input[2][i] is None:
      return True
  if input[0][0] is None and input[1][1] is None and input[2][2] is None:
    return True
  if input[0][2] is None and input[1][1] is None and input[2][0] is None:
  	return True

bingoCard=[] 
bingoCard.append(list(map(int,input().split())))
bingoCard.append(list(map(int,input().split())))
bingoCard.append(list(map(int,input().split())))

readTimes = int(input())
readNumbers = [int(input()) for i in range(readTimes)]

for row in range(3):
  for col in range(3):
    if bingoCard[row][col] in readNumbers:
      bingoCard[row][col] = None
if isBingo(bingoCard):
  print('Yes')
else:
  print('No')

Solution (Python):
b=[]
c=[0]*9
for i in range(3):
  a=input().split()
  b.append(int(a[0]))
  b.append(int(a[1]))
  b.append(int(a[2]))
N=int(input())
for i in range(N):
  e=int(input())
  for j in range(9):
    if(e==b[j]):
      c[j]=1
if(c[0]==c[1]==c[2]==1):
  print('Yes')
elif(c[3]==c[4]==c[5]==1):
  print('Yes')
elif(c[6]==c[7]==c[8]==1):
  print('Yes')
elif(c[0]==c[4]==c[8]==1):
  print('Yes')
elif(c[2]==c[4]==c[6]==1):
  print('Yes')
elif(c[0]==c[3]==c[6]==1):
  print('Yes')
elif(c[1]==c[4]==c[7]==1):
  print('Yes')
elif(c[2]==c[5]==c[8]==1):
  print('Yes')
else:
  print('No')

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


n = int(input())

bs = []
for i in range(n):
    bs.append(int(input()))


ans1 = False
for i in range(3):
    a = True
    for j in range(3):
        if ls[i][j] in bs:
            continue
        else:
            a = False
    if a == True:
        ans1 = True
        break
    else:
        continue

ans4 = False
for i in range(3):
    a = True
    for j in range(3):
        if ls[j][i] in bs:
            continue
        else:
            a = False
    if a == True:
        ans4 = True
        break
    else:
        continue

ans2 = False
if (ls[0][0] in bs) and (ls[1][1] in bs) and (ls[2][2] in bs):
    ans2 = True

ans3 = False
if (ls[2][0] in bs) and (ls[1][1] in bs) and (ls[0][2] in bs):
    ans3 = True


if (ans1 == True) or (ans2 == True) or (ans3 == True) or (ans4 == True):
    print("Yes")
else:
    print("No")

Solution (Python):

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

n = int(input())
for i in range(n):
    b = int(input())
    if b in a:
        k = a.index(b)
        bit[k//3][k%3] = 1

for i in range(3):
    if bit[i][0]*bit[i][1]*bit[i][2] == 1:
        print("Yes")
        exit()
    if bit[0][i]*bit[1][i]*bit[2][i] == 1:
        print("Yes")
        exit()
if bit[0][0]*bit[1][1]*bit[2][2] == 1 or bit[2][0]*bit[1][1]*bit[0][2] == 1:
    print("Yes")
    exit()
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())
b=[int(input()) for i in range(N)]

B=[A1[0], A2[1], A3[2]]
C=[A1[2], A2[1], A3[0]]
D=[A1[0], A2[0], A3[0]]
E=[A1[1], A2[1], A3[1]]
F=[A1[2], A2[2], A3[2]]


answer='No'
if len(set(A1) & set(b))>2:
  answer='Yes'
if len(set(A2) & set(b))>2:
  answer='Yes'
if len(set(A3) & set(b))>2:
  answer='Yes'
if len(set(B) & set(b))>2:
  answer='Yes'
if len(set(C) & set(b))>2:
  answer='Yes'
if len(set(D) & set(b))>2:
  answer='Yes'
if len(set(E) & set(b))>2:
  answer='Yes'
if len(set(F) & set(b))>2:
  answer='Yes'
print(answer)

Solution (Python):
nmap = {}

for i in range(3):
    row = [int(n) for n in input().split()]
    for j in range(3):
        number = row[j]
        nmap[number] = [i, j]

N = int(input())

b = [None] * N

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

lines = [
    [[0, 0], [0, 1], [0, 2]],
    [[1, 0], [1, 1], [1, 2]],
    [[2, 0], [2, 1], [2, 2]],

    [[0, 0], [1, 0], [2, 0]],
    [[0, 1], [1, 1], [2, 1]],
    [[0, 2], [1, 2], [2, 2]],

    [[0, 0], [1, 1], [2, 2]],
    [[2, 0], [1, 1], [0, 2]],
]

for number in b:
    if number in nmap:
        for line in lines:
            if nmap[number] in line:
                line.remove(nmap[number])

ans = "No"
for line in lines:
    if len(line) == 0:
        ans = "Yes"

print(ans)

Solution (Python):
import math
size = 3
bingo = []
for i in range(size):
    line = [int(i) for i in input().split(' ')]
    bingo.append(line)
n = int(input())
bs = []
for i in range(n):
    b = int(input())
    bs.append(b)

flag = False
cnt1 = 0
cnt2 = 0
for i in range(size):
    if bingo[i][i] in bs:
        for j in range(size):
            if bingo[i][j] in bs:
                continue
            else:
                break
        else:
            flag = True
        for j in range(size):
            if bingo[j][i] in bs:
                continue
            else:
                break
        else:
            flag = True
        cnt1 += 1
    if bingo[i][size-i-1] in bs:
        cnt2 += 1
if (cnt1 == size) or (cnt2 == size):
    flag = True

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