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=[]
k=[[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):
  b=int(input())
  for j in range(3):
    for l in range(3):
      if A[j][l]==b:
        k[j][l]=1

        
if k[0]==[1,1,1] or k[1]==[1,1,1] or k[2]==[1,1,1] or (k[0][0]==1 and k[1][0]==1 and k[2][0]==1)or(k[0][1]==1 and k[1][1]==1 and k[2][1]==1)or(k[0][2]==1 and k[1][2]==1 and k[2][2]==1)or(k[0][0]==1 and k[1][1]==1 and k[2][2]==1)or(k[0][2]==1 and k[1][1]==1 and k[2][0]==1):
  print("Yes")
else:
  print("No")

Solution (Python):
import sys
L = list(list(map(int,input().split())) for i in range(3))
n = int(input())
ls = [int(input()) for j in range(n)]
lsls = [0]
lsls[0] = L[0] + L[1] + L[2]
for k in range(n):
    for l in range(9):
        if ls[k] == lsls[0][l]:
            lsls[0][l] = 0
for r in range(3):
    b = [e for e in lsls[0]]
    a = b[r::3]
    if (sum(b[0:3]) ==0) or (sum(b[3:6]) ==0) or(sum(b[6:9]) ==0) or(sum(a) ==0):
        print("Yes")
        sys.exit()
if (lsls[0][0]+lsls[0][4]+lsls[0][8] == 0) or (lsls[0][2]+lsls[0][4]+lsls[0][6] == 0):
    print("Yes")
    sys.exit()
print("No")

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

n = int(input())

for j in range(n):
    b = int(input())
    for k in range(9):
        if a[k] == b:
            a[k] = 0
        
if a[0] == 0 and a[1] == 0 and a[2] == 0:
    print('Yes')
elif a[3] == 0 and a[4] == 0 and a[5] == 0:
    print('Yes')
elif a[6] == 0 and a[7] == 0 and a[8] == 0:
    print('Yes')
elif a[0] == 0 and a[3] == 0 and a[6] == 0:
    print('Yes')
elif a[1] == 0 and a[4] == 0 and a[7] == 0:
    print('Yes')
elif a[2] == 0 and a[5] == 0 and a[8] == 0:
    print('Yes')
elif a[0] == 0 and a[4] == 0 and a[8] == 0:
    print('Yes')
elif a[2] == 0 and a[4] == 0 and a[6] == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
A1 = input().split()
A2 = input().split()
A3 = input().split()
n = int(input())
B = []
for _ in range(n):
    B.append(input())
C1 = []
C2 = []
C3 = []
for Ae in A1:
    if Ae in B:
        C1.append('t')
    else:
        C1.append('f')
for Ae in A2:
    if Ae in B:
        C2.append('t')
    else:
        C2.append('f')
for Ae in A3:
    if Ae in B:
        C3.append('t')
    else:
        C3.append('f')



D1 = [C1[0], C2[0], C3[0]]
D2 = [C1[1], C2[1], C3[1]]
D3 = [C1[2], C2[2], C3[2]]
E1 = [C1[0], C2[1], C3[2]]
E2 = [C1[2], C2[1], C3[0]]

if 'f' not in C1 or 'f' not in C2 or 'f' not in C3:
    print('Yes')
    exit()
if 'f' not in D1 or 'f' not in D2 or 'f' not in D3:
    print('Yes')
    exit()
if 'f' not in E1 or 'f' not in E2:
    print('Yes')
    exit()
print('No')

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

    N = int(input())

    

    result = [[False for i in range(3)] for j in range(3)]

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

    ans = "No"

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

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

    if result[0][0] and result[1][1] and result[2][2] is True:
        ans = "Yes"

    if result[2][0] and result[1][1] and result[0][2] is True:
        ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
A = [0]*3
nums = set([])
for i in range(3):
    A[i] = list(map(int,input().split()))
    for j in A[i]:
        nums.add(j)
N = int(input())

for i in range(N):
    b = int(input())
    if b in nums:
        for i in range(3):
            try:
                ind = A[i].index(b)
                A[i][ind] = 0
            except ValueError:
                continue

ans = 0
for i in range(3):
    if sum(A[i]) == 0:
        ans += 1

for j in range(3):
    tmp = 0
    for k in range(3):
        tmp += A[k][j]
    if tmp == 0:
        ans += 1

tmp = 0
tmp2 = 0
for m in range(3):
    tmp += A[m][m]
    tmp2 += A[m][-m-1]
if tmp == 0:
    ans += 1
if tmp2 == 0:
    ans += 1

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

Solution (Python):
import sys

def input():
    return sys.stdin.readline().strip()


    
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
bingo = "No"
for i in range(n):
    b[i] = int(input())
    for k in range(3):
        if a[k][0] == b[i]:
            a[k][0] = 0
        if a[k][1] == b[i]:
            a[k][1] = 0
        if a[k][2] == b[i]:
            a[k][2] = 0
for i in range(3):
    if a[i][0]+a[i][1]+a[i][2] == 0:
        bingo = "Yes"
for i in range(3):
    if a[0][i]+a[1][i]+a[2][i] == 0:
        bingo = "Yes"
if a[0][0]+a[1][1]+a[2][2] == 0:
    bingo = "Yes"
if a[2][0]+a[1][1]+a[0][2] == 0:
    bingo = "Yes"
 
print(bingo)

Solution (Python):
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    
    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
    bingo = "No"
    for i in range(n):
        b[i] = int(input())
        for k in range(3):
            if a[k][0] == b[i]:
                a[k][0] = 0
            if a[k][1] == b[i]:
                a[k][1] = 0
            if a[k][2] == b[i]:
                a[k][2] = 0
    for i in range(3):
        if a[i][0]+a[i][1]+a[i][2] == 0:
            bingo = "Yes"
    for i in range(3):
        if a[0][i]+a[1][i]+a[2][i] == 0:
            bingo = "Yes"
    if a[0][0]+a[1][1]+a[2][2] == 0:
        bingo = "Yes"
    if a[2][0]+a[1][1]+a[0][2] == 0:
        bingo = "Yes"
     
    print(bingo)
main()

Solution (Python):
A = []
ans = 'No'
for i in range(3):
    A.append(list(map(int,input().split())))
n = int(input())
b = 0
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] = 0
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 or 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):
card = [list(map(int,list(input().split()))) for i in range(3)]
n = n=int(input())
s=[int(input()) for i in range(n)]
ans = "No"

for i in card:
    for j in i:
        if j in s:
            location = i.index(j)
            i[location] = -1

if card[0][0] == card[1][0] == card[2][0] == -1 or card[0][1] == card[1][1]== card[2][1] == -1 or card[0][2] == card[1][2] == card[2][2] == -1:
    ans = "Yes"
    
if card[0] == [-1, -1, -1]:
    ans = "Yes"
if card[1] == [-1, -1, -1]:
    ans = "Yes"
if card[2] == [-1, -1, -1]:
    ans = "Yes"

if card[0][0] == card[1][1] == card[2][2] == -1 or card[0][2] == card[1][1]== card[2][0] == -1:
    ans = "Yes"

print(ans)

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")



def main():
    A = []
    for _ 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 A[i][j] == b:
                    A[i][j] = 0
    
    ans = "No"
    for i in range(3):
        if A[i][0] == A[i][1] and A[i][1] == A[i][2]:
            ans = "Yes"
            break
    for j in range(3):
        if A[0][j] == A[1][j] and A[1][j] == A[2][j]:
            ans = "Yes"
            break
    
    if A[0][0] == A[1][1] and A[1][1] == A[2][2]:
        ans = "Yes"
    if A[0][2] == A[1][1] and A[1][1] == A[2][0]:
        ans = "Yes"

    print(ans)


if __name__ == '__main__':
    main()

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
bingo = "No"
for i in range(n):
    b[i] = int(input())
    for k in range(3):
        if a[k][0] == b[i]:
            a[k][0] = 0
        if a[k][1] == b[i]:
            a[k][1] = 0
        if a[k][2] == b[i]:
            a[k][2] = 0
for i in range(3):
    if a[i][0]+a[i][1]+a[i][2] == 0:
        bingo = "Yes"
for i in range(3):
    if a[0][i]+a[1][i]+a[2][i] == 0:
        bingo = "Yes"
if a[0][0]+a[1][1]+a[2][2] == 0:
    bingo = "Yes"
if a[2][0]+a[1][1]+a[0][2] == 0:
    bingo = "Yes"

print(bingo)

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

numbers = []

for _ in range(num_of_number):
    numbers.append(int(input()))

for number in numbers:
    for i, A in enumerate(A1):
        if A in numbers:
            A1[i] = -1

    for i, A in enumerate(A2):
        if A in numbers:
            A2[i] = -1

    for i, A in enumerate(A3):
        if A in numbers:
            A3[i] = -1


if A1.count(-1) == 3 or A2.count(-1) == 3 or A3.count(-1) == 3:
    print('Yes')
    exit()


V1_count = [A1[0], A2[0], A3[0]].count(-1)
V2_count = [A1[1], A2[1], A3[1]].count(-1)
V3_count = [A1[2], A2[2], A3[2]].count(-1)
if V1_count == 3 or V2_count == 3 or V3_count == 3:
    print('Yes')
    exit()


D1_count = [A1[0], A2[1], A3[2]].count(-1)
D2_count = [A1[2], A2[1], A3[0]].count(-1)
if D1_count == 3 or D2_count == 3:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    A = [NLI() for _ in range(3)]
    N = NI()
    B = [NI() for _ in range(N)]
    hit = [[0]*3 for _ in range(3)]
    for b in B:
        for i in range(3):
            for j in range(3):
                if b == A[i][j]:
                    hit[i][j] = 1

    for h in hit:
        if sum(h) == 3:
            print("Yes")
            exit()
    for j in range(3):
        if hit[0][j] + hit[1][j] + hit[2][j] == 3:
            print("Yes")
            exit()
    if hit[0][2] + hit[1][1] + hit[2][0] == 3:
        print("Yes")
        exit()
    if hit[0][0] + hit[1][1] + hit[2][2] == 3:
        print("Yes")
        exit()
    print("No")



if __name__ == "__main__":
    main()

Solution (Python):
square = [input().split(" "), input().split(" "), input().split(" ")]
n = int(input())

for i in range(n):
    num = input()
    for row in square:
        if num in row:
            row[row.index(num)] = 'x'

if square[0][0] == square[0][1] == square[0][2] == 'x' or square[1][0] == square[1][1] == square[1][2] == 'x' or square[2][0] == square[2][1] == square[2][2] == 'x' or square[0][0] == square[1][0] == square[2][0] == 'x' or square[0][1] == square[1][1] == square[2][1] == 'x' or square[0][2] == square[1][2] == square[2][2] == 'x' or square[0][0] == square[1][1] == square[2][2] == 'x' or square[0][2] == square[1][1] == square[2][0] == 'x':
    print('Yes')
else:
    print('No')

Solution (Python):
a = [[0]*3]*3
for i in range(3):
  a[i] = list(map(int,input().split()))
  
def isInList(b,a):
  for i in range(len(a)):
    for j in range(len(a[i])):
      if a[i][j] == b:
        return i,j
      
  return -1,-1
  
N = int(input())
for i in range(N):
  b = int(input())
  I,J = isInList(b,a)
  if I != -1:
    a[I][J] = -1
    

def judge(a):
  for i in range(3):
    if a[i][0] == -1 and a[i][1] == -1 and a[i][2] == -1:
      return True
  for i in range(3):
    if a[0][i] == -1 and a[1][i] == -1 and a[2][i] == -1:
      return True
  tmp = [a[i][i] for i in range(3)]
  if tmp == [-1,-1,-1]:
    return True
  tmp = [a[i][2-i] for i in range(3)]
  if tmp == [-1,-1,-1]:
    return True
  return False


ans = "Yes" if judge(a) else "No"
print(ans)

Solution (Python):
a = []
for x in range(3):
    a.append(list(map(int, input().split())))
row = [0] * 3
col = [0] * 3
sli = [0] * 2

c = [[False] * 3 for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for x in range(3):
        for y in range(3):
            if a[x][y] == b:
                c[x][y] = True
flag = False
for i in range(3):
    if c[i].count(True) == 3:
        flag = True
    if c[0][i] == c[1][i] == c[2][i] == True:
        flag = True
if c[0][0] == c[1][1] == c[2][2] == True:
    flag = True
if c[0][2] == c[1][1] == c[2][0] == True:
    flag = True

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

Solution (Python):
import numpy as np

A = np.zeros((3, 3))
for i in range(3):
    A[i] = list(map(int, input().split()))

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

N = int(input())
b = np.zeros((N, 1))

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

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

hit_T = hit.T

if hit[0][0] + hit[1][1] + hit[2][2] == 3 or \
    hit[0][2] + hit[1][1] + hit[2][0] == 3:
    print('Yes')
    exit()

for i in range(3):
    if sum(hit[i]) == 3:
        print('Yes')
        exit()
    if sum(hit_T[i]) == 3:
        print('Yes')
        exit()

print('No')

Solution (Python):
A=[[int(i) for i in input().split()] for q in range(3)]
n=int(input())

tar=[]
for i in range(n):
  ck=int(input())
  for p in range(9):
    if A[p//3][p%3] == ck:
      tar.append(p)
      
def check(a,b,c):
  if a in tar and b in tar and c in tar:
    return 1
  else:
    return 0
  
res=check(0,1,2)+check(3,4,5)+check(6,7,8)+check(0,3,6)+check(1,4,7)+check(2,5,8)+check(0,4,8)+check(2,4,6)
if res == 0:
  print("No")
else:
  print("Yes")

Solution (Python):
a1,a2,a3=map(int,input().split())
b1,b2,b3=map(int,input().split())
c1,c2,c3=map(int,input().split())
l=[[0]*3 for _ in range(3)]
n=int(input())
for _ in range(n):
    b=int(input())
    if a1==b:
        l[0][0]=1
    elif a2==b:
        l[0][1]=1
    elif a3==b:
        l[0][2]=1
    elif b1==b:
        l[1][0]=1
    elif b2==b:
        l[1][1]=1
    elif b3==b:
        l[1][2]=1
    elif c1==b:
        l[2][0]=1
    elif c2==b:
        l[2][1]=1
    elif c3==b:
        l[2][2]=1
if l[0]==[1,1,1] or l[1]==[1,1,1] or l[2]==[1,1,1]:
    print('Yes')
elif l[0][0]==1 and l[1][0]==1 and l[2][0]==1 or l[0][1]==1 and l[1][1]==1 and l[2][1]==1 or l[0][2]==1 and l[1][2]==1 and l[2][2]==1:
    print('Yes')
elif l[0][0]==1 and l[1][1]==1 and l[2][2]==1 or l[0][2]==1 and l[1][1] and l[2][0]==1:
    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)]
set(b)

bingo = 0
checker = 0

for i in range(len(b)):
  for j in range(3):
    for k in range(3):
      if a[j][k] == b[i]:
        a[j][k] = "o"
        checker += 1

if checker > 0:       
  for l in range(3):
    if a[l].count("o") == 3:
      bingo += 1
    if a[0][l] == a[1][l] == a[2][l] == "o":
      bingo += 1
  if a[0][0] == a[1][1] == a[2][2] == "o":
    bingo += 1
  if a[0][2] == a[1][1] == a[2][0] == "o":
    bingo += 1
    
if bingo > 0:
  print("Yes")
else:
  print("No")

Solution (Python):
bingo = []
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):
    n = int(input())
    if n in a:
        a[a.index(n)] = 0
    elif n in b:
        b[b.index(n)] = 0
    elif n in c:
        c[c.index(n)] = 0

if sum(a) == 0 or sum(b) == 0 or sum(c) == 0 or a[0]+ b[1] + c[2] == 0 or a[2] + b[1] + c[0] == 0 :
    print("Yes")
elif a[0] + b[0]+ c[0] ==0 or a[1] + b[1]+ c[1] == 0 or a[2] + b[2]+ c[2] == 0 :
    print("Yes")
else:print("No")

Solution (Python):
A1 = map(int, input().split())
A2 = map(int, input().split())
A3 = map(int, input().split())
N = int(input())
b = [int(input()) for x in range(N)]
A1_check = []
A2_check = []
A3_check = []

for i, item in enumerate(A1):
    if item in b:
        A1_check.append(i+1)

for i, item in enumerate(A2):
    if item in b:
        A2_check.append(i+1)

for i, item in enumerate(A3):
    if item in b:
        A3_check.append(i+1)

if (len(A1_check) == 3 or \
len(A2_check) == 3 or \
len(A3_check) == 3 or \
(1 in A1_check and 1 in A2_check and 1 in A3_check) or \
(2 in A1_check and 2 in A2_check and 2 in A3_check) or \
(3 in A1_check and 3 in A2_check and 3 in A3_check) or \
(1 in A1_check and 2 in A2_check and 3 in A3_check) or \
(3 in A1_check and 2 in A2_check and 1 in A3_check)):
    print("Yes")
else:
    print("No")

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

for bi in b_i:
    for i in range(3):
        for j in range(3):
            if A[i][j] == bi:
                A[i][j] = "hole"

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


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

if A[0][0] == "hole" and A[1][1] == "hole" and A[2][2] == "hole":
    ans = "Yes"

if A[0][2] == "hole" and A[1][1] == "hole" and A[2][0] == "hole":
    ans = "Yes"

print(ans)

Solution (Python):
a_list = []
for i in range(3):
    a = list(map(int, input().split()))
    a_list.append(a)
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_list[j]):
            a_list[j][a_list[j].index(b[i])] = 'ok'

yn = 'No'
for i in range(3):
    if a_list[i] == ['ok', 'ok', 'ok']:
        yn = 'Yes'
for i in range(3):
    if a_list[0][i] == 'ok' and a_list[1][i] == 'ok' and a_list[2][i] == 'ok':
        yn = 'Yes'
if a_list[0][0] == 'ok' and a_list[1][1] == 'ok' and a_list[2][2] == 'ok':
    yn = 'Yes'
if a_list[0][2] == 'ok' and a_list[1][1] == 'ok' and a_list[2][0] == 'ok':
    yn = 'Yes'

if yn == 'Yes':
    print('Yes')
else:
    print('No')

Solution (Python):
a=[]
for i in range(3):
  a1,a2,a3=map(int,input().split())
  a.append(a1)
  a.append(a2)
  a.append(a3)
n=int(input())
for i in range(n):
  b=int(input())
  for j in range(9):
    if a[j]==b:
      a[j]=0
if a[0]==0 and a[1]==0 and a[2]==0:
  print("Yes")
elif a[3]==0 and a[4]==0 and a[5]==0:
  print("Yes")
elif a[6]==0 and a[7]==0 and a[8]==0:
  print("Yes")
elif a[0]==0 and a[3]==0 and a[6]==0:
  print("Yes")
elif a[1]==0 and a[4]==0 and a[7]==0:
  print("Yes")
elif a[2]==0 and a[5]==0 and a[8]==0:
  print("Yes")
elif a[0]==0 and a[4]==0 and a[8]==0:
  print("Yes")
elif a[2]==0 and a[4]==0 and a[6]==0:
  print("Yes")
else:
  print("No")

Solution (Python):
As=[]
As.append(list(map(int,input().split())))
As.append(list(map(int,input().split())))
As.append(list(map(int,input().split())))
N=int(input())
is_bingo=False
n=0
while n<N:
  n+=1
  b=int(input())
  for i in range(3):
    for j in range(3):
      if As[i][j] == b:
        As[i][j]=0
  for _ in range(1):
    if As[0][0]+As[0][1]+As[0][2]==0:
      is_bingo=True
      break
    if As[1][0]+As[1][1]+As[1][2]==0:
      is_bingo=True
      break
    if As[2][0]+As[2][1]+As[2][2]==0:
      is_bingo=True
      break
    if As[0][0]+As[1][0]+As[2][0]==0:
      is_bingo=True
      break
    if As[0][1]+As[1][1]+As[2][1]==0:
      is_bingo=True
      break
    if As[0][2]+As[1][2]+As[2][2]==0:
      is_bingo=True
      break
    if As[0][0]+As[1][1]+As[2][2]==0:
      is_bingo=True
      break
    if As[2][0]+As[1][1]+As[0][2]==0:
      is_bingo=True
      break

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

Solution (Python):
grid = []
for _ in range(3): 
    grid.append(list(map(int, input().split())))
ns = [int(input()) for _ in range(int(input()))]
for i in range(3):
    for j in range(3):
        if grid[i][j] in ns:
            grid[i][j]= True
        else:
            grid[i][j] = False
flg = False
for i in range(3):
    if (grid[0][i] and grid[1][i] and grid[2][i]) or (grid[i][0] and grid[i][1] and grid[i][2]) or (grid[0][0] and grid[1][1] and grid[2][2]) or (grid[0][2] and grid[1][1] and grid[2][0]):
        flg = True
        break
if flg:
    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 j in range(N)]
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 len(set(A[i]))==1:
        print("Yes")
        exit()
    if A[0][i]==A[1][i]==A[2][i]==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")
else:
    print("No")

Solution (Python):
import sys

A = list(list(map(int, input().split())) for _ in range(3))
N = int(input())
num = list(int(input()) for _ in range(N))

for i in range(3):
    for j in range(3):
        if A[i][j] in num:
            A[i][j] = -1
            
if A[0][0] == -1 and A[0][1] == -1 and A[0][2] == -1:
    print("Yes")
    sys.exit()
elif A[1][0] == -1 and A[1][1] == -1 and A[1][2] == -1:
    print("Yes")
    sys.exit()
elif A[2][0] == -1 and A[2][1] == -1 and A[2][2] == -1:
    print("Yes")
    sys.exit()
elif A[0][0] == -1 and A[1][0] == -1 and A[2][0] == -1:
    print("Yes")
    sys.exit()
elif A[0][1] == -1 and A[1][1] == -1 and A[2][1] == -1:
    print("Yes")
    sys.exit()
elif A[0][2] == -1 and A[1][2] == -1 and A[2][2] == -1:
    print("Yes")
    sys.exit()
elif A[0][0] == -1 and A[1][1] == -1 and A[1][1] == -1:
    print("Yes")
    sys.exit()
elif A[0][2] == -1 and A[1][1] == -1 and A[2][0] == -1:
    print("Yes")
    sys.exit()
    
print("No")

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

chk = [[False for i in range(3)] for j in range(3)]

for i in range(n):
	x = b[i]
	for j in range(3):
		for k in range(3):
			if a[j][k] == x:
				chk[j][k] = True

flg = False
if chk[0][0] and chk[0][1] and chk[0][2]:
	flg = True
if chk[1][0] and chk[1][1] and chk[1][2]:
	flg = True
if chk[2][0] and chk[2][1] and chk[2][2]:
	flg = True
if chk[0][0] and chk[1][0] and chk[2][0]:
	flg = True
if chk[0][1] and chk[1][1] and chk[2][2]:
	flg = True
if chk[0][2] and chk[1][2] and chk[2][2]:
	flg = True
if chk[0][0] and chk[1][1] and chk[2][2]:
	flg = True
if chk[0][2] and chk[1][1] and chk[2][0]:
	flg = True

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

Solution (Python):
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for c in range(3):
        for r in range(3):
            if a[c][r] == b:
                a[c][r] = 0
R = [0,0,0]
C = [0,0,0]
S = [0,0]
for i in range(3):
    for j in range(3):
        R[i] += a[i][j]  
        C[j] += a[i][j]  
for i in range(3):  
    S[0] += a[i][i]
    S[1] += a[i][2-i]
print('Yes' if 0 in R + C + S else 'No')

Solution (Python):

card = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = list([int(input()) for _ in range(N)])
a = [[0]*3 for _ in range(3)]
for bi in b:
    for i in range(3):
        for j in range(3):
            if bi == card[i][j]:
                a[i][j] = 1
                
ans = 'No'

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

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

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

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

ans = "No"

if not(sum(a[0]) and sum(a[1]) and sum(a[2]) and 
        sum([a[0][0],a[1][0],a[2][0]]) and sum([a[0][1],a[1][1],a[2][1]]) and sum([a[0][2],a[1][2],a[2][2]]) and
        sum([a[0][0],a[1][1],a[2][2]]) and sum([a[0][2],a[1][1],a[2][0]])):
    ans = "Yes"

print(ans)

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

for i in range(N):
    B = int(input())
    for c in range(3):
        for r in range(3):
            if A[c][r] == B:
                A[c][r] = 0

R = [0, 0, 0]
C = [0, 0, 0]
S = [0, 0]

for i in range(3):
    for j in range(3):
        R[i] += A[i][j]
        C[j] += A[i][j]

for i in range(3):
    S[0] += A[i][i]
    S[1] += A[i][2 - i]

print('Yes' if 0 in R + C + S else 'No')

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

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

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

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

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

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

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

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

for num in nums:
    for index, card_num in enumerate(b_card):
        if num in card_num:
            card_st[index][card_num.index(num)] = 1

if True in np.all(card_st, axis=0):
    print('Yes')
elif True in np.all(card_st, axis=1):
    print('Yes')
elif np.all(np.diag(card_st) == 1):
    print('Yes')
elif np.all(np.diag(np.fliplr(card_st)) == 1):
    print('Yes')
else:
    print('No')

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

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

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

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

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

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

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

if bingo[ 0 ][ 2 ] and bingo[ 1 ][ 1 ] and bingo[ 2 ][ 0 ]:
    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()))
a = a1+a2+a3

n = int(input())

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

if a[0]==a[1]==a[2] or a[3]==a[4]==a[5] or a[6]==a[7]==a[8] or a[0]==a[3]==a[6]\
or a[1]==a[4]==a[7] or a[2]==a[5]==a[8] or a[0]==a[4]==a[8] or a[2]==a[4]==a[6]:
    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)]

if a1[0] in b and a1[1] in b and a1[2] in b:
  print('Yes')
elif a2[0] in b and a2[1] in b and a2[2] in b:
  print('Yes')
elif a3[0] in b and a3[1] in b and a3[2] in b:
  print('Yes')
elif a1[0] in b and a2[0] in b and a3[0] in b:
  print('Yes')
elif a1[1] in b and a2[1] in b and a3[1] in b:
  print('Yes')
elif a1[2] in b and a2[2] in b and a3[2] in b:
  print('Yes')
elif a1[0] in b and a2[1] in b and a3[2] in b:
  print('Yes')
elif a1[2] in b and a2[1] in b and a3[0] in b:
  print('Yes')
else:
  print('No')

Solution (Python):
import numpy as np
a = np.array([input().split() for _ in range(3)])
n = int(input())
b = [int(input()) for _ in range(n)]

def bingo(sheet, called):
    sheet = np.where(sheet == called, 0, sheet)
    return sheet

for i in range(n):
    a = bingo(a, str(b[i]))


check = 0
for j in range(3):
    if a[j][0] == a[j][1] and a[j][2] == a[j][0] == '0':
        check += 1
    if a[0][j] == a[1][j] and a[2][j] == a[0][j] == '0':
        check += 1
if a[0][0] == a[1][1] and a[2][2] == a[0][0] == '0':
    check += 1
if a[0][2] == a[1][1] and a[2][0] == a[0][2] == '0':
    check += 1

print('No' if check == 0 else 'Yes')

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

C = []
  
C.append(A[0])
C.append(A[1])
C.append(A[2])
C.append([A[0][0], A[1][0], A[2][0]])
C.append([A[0][1], A[1][1], A[2][1]])
C.append([A[0][2], A[1][2], A[2][2]])
C.append([A[0][0], A[1][1], A[2][2]])
C.append([A[0][2], A[1][1], A[2][0]])

flag = False

for c in C:
  if len(set(c)&set(B)) == 3:
    flag = True
    break
    
if flag:
  print("Yes")
else:
  print("No")