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):
import numpy as np	
import sys
stdin = open(0)
K1 = (stdin.readline()).split()
K2 = (stdin.readline()).split()
K3 = (stdin.readline()).split()
KKK = np.array([K1,K2,K3], dtype='int')
N = np.array((stdin.readline()).split(),dtype='int')
K = np.array(stdin.readlines())
for i in range(len(K)):
  K[i] = K[i].replace('\n','')
K = np.array(K, dtype='int')

AAA = np.zeros((3,3),dtype='int')
for i in range(3):
  for j in range(3):
    for k in K:
      if KKK[i,j] == k:
        AAA[i,j] = 1
for i in range(3):
  if np.sum(AAA[i,:]) == 3:
    print('Yes')
    sys.exit()
  if np.sum(AAA[:,i]) == 3:
    print('Yes')
    sys.exit()
if (AAA[0,0]+AAA[1,1]+AAA[2,2])==3:
    print('Yes')
    sys.exit()
if (AAA[0,2]+AAA[1,1]+AAA[2,0])==3:
    print('Yes')
    sys.exit()
print('No')

Solution (Python):
a1=[int(i) for i in input().split()]
a2=[int(i) for i in input().split()]
a3=[int(i) for i in input().split()]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        if a1[j]==b: a1[j]=-1
        if a2[j]==b: a2[j]=-1
        if a3[j]==b: a3[j]=-1
if a1[0]+a2[0]+a3[0]==-3 or a1[1]+a2[1]+a3[1]==-3 or a1[2]+a2[2]+a3[2]==-3:
    print("Yes")
    exit()
print("Yes" if sum(a1)==-3 or sum(a2)==-3 or sum(a3)==-3 or a1[0]+a2[1]+a3[2]==-3 or a1[2]+a2[1]+a3[0]==-3 else "No" )

Solution (Python):
init = list(input().split() for _ in range(3))

flag = 0

n = int(input())


for i in range(n):
    num = int(input())
    for j in range(3):
        for l in range(3):
            if(int(init[j][l]) == num):
                init[j][l] = 0

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

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


if(init[0][0] == init[1][1] == init[2][2] == 0):
    flag = 1
    
if(init[0][2] == init[1][1] == init[2][0] == 0):
    flag = 1


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

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

if N < 3:
    print("No")
    exit()

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

yes = False

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


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

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

Chosen = []
for _ in range(3):
    Chosen.append([False] * 3)

Bingo = [
    [[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]]
    ]

ans = False

for sample in b:
    for i in range(3):
        for j in range(3):
            if A[i][j] == sample:
                Chosen[i][j] = True

for i in range(len(Bingo)):
    if Chosen[Bingo[i][0][0]][Bingo[i][0][1]] and Chosen[Bingo[i][1][0]][Bingo[i][1][1]] and Chosen[Bingo[i][2][0]][Bingo[i][2][1]]:
        ans = True
        break

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

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

count = [[0,0,0],[0,0,0],[0,0,0]]

for i in range(0,n):
   for j in range(0,3):
      for k in range(0,3):
         if alist[i] == blist[j][k]:
            count[j][k] += 1

ans = 0
temp = 0

for i in range(0,3):
   for k in range(0,3):
      if count[i][k] == 1:
         temp += 1
      if temp == 3:
         ans += 1
   temp = 0

for i in range(0,3):
   for k in range(0,3):
      if count[k][i] >= 1:
         temp += 1
      if temp == 3:
         ans += 1
   temp = 0

if count[0][0] == 1 and count[1][1] == 1 and count[2][2] == 1:
   ans += 1
if count[0][2] == 1 and count[1][1] == 1 and count[2][0] == 1:
   ans += 1

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

Solution (Python):
grid = [[0 for i in xrange(3)] for j in xrange(3)]
for i in xrange(3):
    grid[i] = map(int, raw_input().strip().split())

ans = [[0 for i in xrange(3)] for j in xrange(3)]

q = input()
for _ in xrange(q):
    num = input()
    for i in xrange(3):
        for j in xrange(3):
            if grid[i][j] == num:
                ans[i][j] = 1

yes = "No"
for i in xrange(3):
    if ans[i] == [1, 1, 1]:
        yes = "Yes"

for i in xrange(3):
    if [ans[j][i] for j in xrange(3)] == [1, 1, 1]:
        yes = "Yes"

if [ans[i][i] for i in xrange(3)] == [1, 1, 1]:
    yes = "Yes"

if [ans[2][0], ans[1][1], ans[0][2]] == [1, 1, 1]:
    yes = "Yes"

print yes

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

for i in range(n):
    if b[i]==a1[0]:
        an[0]=1
    if b[i]==a1[1]:
        an[1]=1
    if b[i]==a1[2]:
        an[2]=1
    if b[i]==a2[0]:
        an[3]=1
    if b[i]==a2[1]:
        an[4]=1
    if b[i]==a2[2]:
        an[5]=1
    if b[i]==a3[0]:
        an[6]=1
    if b[i]==a3[1]:
        an[7]=1
    if b[i]==a3[2]:
        an[8]=1



if an[0]==1 and an[1]==1 and an[2]==1:
    print("Yes")
elif an[3]==1 and an[4]==1 and an[5]==1:
    print("Yes")
elif an[6]==1 and an[7]==1 and an[8]==1:
    print("Yes")
elif an[0]==1 and an[3]==1 and an[6]==1:
    print("Yes")
elif an[1]==1 and an[4]==1 and an[7]==1:
    print("Yes")
elif an[2]==1 and an[5]==1 and an[8]==1:
    print("Yes")
elif an[0]==1 and an[4]==1 and an[8]==1:
    print("Yes")
elif an[2]==1 and an[4]==1 and an[6]==1:
    print("Yes")
else:
    print("No")

Solution (Python):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
board = [a, b, c]

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

result = [[False] * 3, [False] * 3, [False] * 3]


for x in l:
  for i in range(3):
    for j in range(3):
      if x == board[i][j]:
        result[i][j] = True
        
ans = False

for i in result:
  if all(i):
    ans = True

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

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

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

Solution (Python):
import numpy as np
a_1 = list(map(int,input().split()))
a_2 = list(map(int,input().split()))
a_3 = list(map(int,input().split()))
a = []
a.append(a_1)
a.append(a_2)
a.append(a_3)
bingo = [[False] * 3 for _ in range(3)]
n = int(input())
for _ in range(n):
    tmp = int(input())
    for x,row in enumerate(a):
        try:
            pos = [x,row.index(tmp)]
            bingo[pos[0]][pos[1]] = True
            break
        except ValueError:
            pass
bingo = np.array(bingo)
if (sum(bingo[0]) == 3) | (sum(bingo[1])==3) | (sum(bingo[2])==3) | (3 in np.sum(bingo,axis=0)):
    print('Yes')
elif ((bingo[0][0]==True) & (bingo[1][1]==True) & (bingo[2][2]==True)) | ((bingo[0][2]==True) & (bingo[1][1]==True) & (bingo[2][0]==True)):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
import numpy as np
A = []
for n in range(3):
    tmp_lis = list(map(int, input().split()))
    A.append(tmp_lis)
N = int(input())

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

if N <= 2:
    print("No")
    sys.exit()

bool_lis = [[False, False, False],
            [False, False, False],
            [False, False, False]]

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            bool_lis[i][j] = True

arr = np.array(bool_lis)

if (np.trace(arr) == 3) or all([arr[0][2], arr[1][1], arr[2][0]]) or (3 in sum(arr)) or (3 in sum(arr.T)):
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import defaultdict
D  = [list(map(int, s.split())) for s in open(0)]
bingo = D[0:3]
num = [d[0] for d in D[4:]]
n = []
cases = [
    [(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)],  
    [(0,2), (1, 1), (2, 0)]]
for i in range(len(bingo)):
    for j in range(len(bingo[i])):
        if bingo[i][j] in num:
            n.append((i, j))
flag = 0
for c in cases:
    f = 0
    for l in c:
        if l in n:
            f += 1
    if f == 3:
        flag += 1
        
if flag:
    print("Yes")
else:
    print("No")

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


judge = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

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

bool = False

for i in range(3):
    if judge[i][0] == 1 and judge[i][1] == 1 and judge[i][2] == 1:
        print('Yes')
        bool = True
        break
    elif judge[0][i] == 1 and judge[1][i] == 1 and judge[2][i] == 1:
        print('Yes')
        bool = True
        break
    elif judge[0][0] == 1 and judge[1][1] == 1 and judge[2][2] == 1:
        print('Yes')
        bool = True
        break
    elif judge[0][2] == 1 and judge[1][1] == 1 and judge[2][0] == 1:
        print('Yes')
        bool = True
        break

if bool == False:
    print('No')

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

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

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

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

if a[0][0] == True and a[1][1] == True and a[2][2] == True:
    print("Yes")
    exit()

if a[2][0] == True and a[1][1] == True and a[0][2] == True:
    print("Yes")
    exit()

print("No")

Solution (Python):
r1 = list(map(int,input().split()))
r2 = list(map(int,input().split()))
r3 = list(map(int,input().split()))
r1.extend(r2)
r1.extend(r3)
N = int(input())
for i in range(N):
    num = int(input())
    if num in r1:
        r1[r1.index(num)] = 0
ans = False
if sum(r1[::3]) == 0 or sum(r1[1::3]) == 0 or sum(r1[2::3]) == 0:
    ans = True
elif sum(r1[:3]) == 0 or sum(r1[3:6]) == 0 or sum(r1[6:]) == 0:
    ans = True
elif (r1[0]+r1[4]+r1[8]) == 0 or (r1[2]+r1[4]+r1[6]) == 0:
    ans = True
if ans:
    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()))
b = set(b)
row = []
col = []
diag = []
for i in range(3):
    tmp1 = []
    tmp2 = []
    for j in range(3):
        tmp1.append(a[i][j])
        tmp2.append(a[j][i])
    row.append(set(tmp1))
    col.append(set(tmp2))

tmp3 = []
tmp4 = []
for i in range(3):
    tmp3.append(a[i][i])
    tmp4.append(a[i][2-i])
diag.append(set(tmp3))
diag.append(set(tmp4))

bingo = False
for i in range(3):
    if row[i] <= b or col[i] <= b:
        bingo = True
for i in range(2):
    if diag[i] <= b:
        bingo = True

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

Solution (Python):
a1 = input().split()
a2 = input().split()
a3 = input().split()
A = [a1, a2, a3]
N = input()
N = int(N)

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

ans = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

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

flag = False
if sum(ans[0]) == 3 or sum(ans[1]) == 3 or sum(ans[2]) == 3:
	flag = True
if (ans[0][0] + ans[1][0] + ans[2][0]) == 3:
	flag = True
if (ans[0][1] + ans[1][1] + ans[2][1]) == 3:
	flag = True
if (ans[0][2] + ans[1][2] + ans[2][2]) == 3:
	flag = True
if (ans[0][0] + ans[1][1] + ans[2][2]) == 3:
	flag = True
if (ans[0][2] + ans[1][1] + ans[2][0]) == 3:
	flag = True

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

Solution (Python):
import sys
a0 = list(map(int,input().split()))
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
c = 0
n = int(input())
for i in range(n):
    b = int(input())
    if a0.count(b) == 1:
        c += 1
        a0[a0.index(b)] = "〇"
    elif a1.count(b) == 1:
        c += 1
        a1[a1.index(b)] = "〇"
    elif a2.count(b) == 1:
        c += 1
        a2[a2.index(b)] = "〇"
if c <= 2:
    print("No")
    sys.exit()
else:
    if a0[0] == "〇":
        if a1[0] == a2[0]:
            print("Yes")
            sys.exit()
        if a0[1] == a0[2]:
            print("Yes")
            sys.exit()
        if a1[1] == a2[2]:
            print("Yes")
            sys.exit()
    if a0[1] == "〇":
        if a1[1] == a2[1]:
            print("Yes")
            sys.exit()
    if a0[2] == "〇":
        if a1[2] == a2[2]:
            print("Yes")
            sys.exit()
        if a1[1] == a2[0]:
            print("Yes")
            sys.exit()
    if a1[0] == a1[1] == a1[2]:
        print("Yes")
        sys.exit()
    if a2[0] == a2[1] == a2[2]:
        print("Yes")
        sys.exit()
print("No")

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

N = int(input())
Flag = False
for k in range(N):
    temp = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == temp:
                A[i][j] = 0
            else:
                next

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


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

Solution (Python):
A11, A12, A13 = map(int, input().split(' '))
A21, A22, A23 = map(int, input().split(' '))
A31, A32, A33 = map(int, input().split(' '))
N = int(input())


A = {"A11":A11,"A12":A12, "A13":A13,
     "A21":A21, "A22":A22, "A23":A23,
     "A31":A31, "A32":A32, "A33":A33}

for _ in range(N):
    b = int(input())
    for k, v in A.items():
        if v == b:
            A[k] = 0

        
bingoset = [["A11", "A12", "A13"],
            ["A21", "A22", "A23"],
            ["A31", "A32", "A33"],
            ["A11", "A21", "A31"],
            ["A12", "A22", "A32"],
            ["A13", "A23", "A33"],
            ["A11", "A22", "A33"],
            ["A13", "A22", "A31"]
           ]

no_flag = 1
for bingo in bingoset:
    if A[bingo[0]] == 0 and A[bingo[1]] == 0 and A[bingo[2]] == 0:
        print('Yes')
        no_flag = 0
        break

if no_flag:
    print('No')

Solution (Python):
bingo = [None]*3
for i in range(3):
    bingo[i] = list(map(int,input().split()))
N= int(input())
lis = [None]*N
for i in range(N):
    temp = int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == temp:
                bingo[j][k] = 0
                break

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

else:
    ans ="No"
    for i in range(3):
        if bingo[0][i] == bingo[1][i] == bingo[2][i] == 0 or bingo[i][0]==bingo[i][1]==bingo[i][2]==0:
            ans = 'Yes'
    print(ans)

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

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

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

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

for i in range(3):
  for j in range(3):
    if j == 2 and A[i][j] in B:
      print("Yes")
      exit()
    if A[i][j] in B: pass
    else: break  
for i in range(3):
  for j in range(3):
    if j == 2 and A[j][i] in B:
      print("Yes")
      exit()
    if A[j][i] in B: pass
    else: break  
for i in range(3):
    if i == 2 and A[i][i] in B:
      print("Yes")
      exit()
    if A[i][i] in B: pass
    else: break  
for i in range(3):
    if i == 2 and A[i][2-i] in B:
      print("Yes")
      exit()
    if A[i][2-i] in B: pass
    else: break  
print("No")

Solution (Python):
gyo1 = list(map(int,input().split()))
gyo2 = list(map(int,input().split()))
gyo3 = list(map(int,input().split()))
 
n = int(input())
for i in range(n):
  detame = int(input())
  if detame in gyo1:
    gyo1[gyo1.index(detame)] = -1
  elif detame in gyo2:
    gyo2[gyo2.index(detame)] = -1
  elif detame in gyo3:
    gyo3[gyo3.index(detame)] = -1
    
if gyo1.count(-1) == 3 or gyo2.count(-1) == 3 or gyo3.count(-1) == 3:
  print('Yes')
  exit()
 
for i in range(3):
  if gyo1[i] == -1 and gyo2[i] == -1 and gyo3[i] == -1 :
    print('Yes')
    exit()
    
if gyo1[0] == -1 and gyo2[1] == -1 and gyo3[2] == -1 : 
  print('Yes')
elif gyo1[2] == -1 and gyo2[1] == -1 and gyo3[0] == -1 : 
  print('Yes')
else:
  print('No')

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

for i, line in enumerate(card):
    for j, pt in enumerate(line):
        if pt in target_list:
            card[i][j] = 1 
        else:
            card[i][j] = 0 

result = False

for l in card:
    if l.count(1) == 3:
        result = True


for l in list(zip(*card)):
    if l.count(1) == 3:
        result = True


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

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

Solution (Python):
A = []
A.append([int(x) for x in input().split()])
A.append([int(x) for x in input().split()])
A.append([int(x) for x in input().split()])

G = [[False] * 3 for i in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for r in range(3):
        for c in range(3):
            if A[r][c] == b:
                G[r][c] = True

def check():
    
    for r in range(3):
        if all(G[r][c] for c in range(3)):
            return "Yes"
    for c in range(3):
        if all(G[r][c] for r in range(3)):
            return "Yes"
    if all(G[c][c] for c in range(3)):
        return "Yes"
    if G[0][2] and G[1][1] and G[2][0]:
        return "Yes"
    return "No"

print(check())

Solution (Python):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    lines = []
    a = list(map(int, sys.stdin.readline().split()))
    b = list(map(int, sys.stdin.readline().split()))
    c = list(map(int, sys.stdin.readline().split()))
    lines.append(a)
    lines.append(b)
    lines.append(c)
    N = int(sys.stdin.readline().rstrip())
    S = [line.rstrip() for line in sys.stdin.readlines()]

    ret = []
    for s in S:
        for i in range(3):
            for j in range(3):
                if int(s) == lines[i][j]:
                    ret.append(str(i) + str(j))

    if "00" in ret and "01" in ret and "02" in ret:
        print("Yes")
    elif "10" in ret and "11" in ret and "12" in ret:
        print("Yes")
    elif "20" in ret and "21" in ret and "22" in ret:
        print("Yes")
    elif "00" in ret and "10" in ret and "20" in ret:
        print("Yes")
    elif "01" in ret and "11" in ret and "21" in ret:
        print("Yes")
    elif "02" in ret and "12" in ret and "22" in ret:
        print("Yes")
    elif "00" in ret and "11" in ret and "22" in ret:
        print("Yes")
    elif "02" in ret and "11" in ret and "20" in ret:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Solution (Python):
A = [[0]*3]*3

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

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

for i in b:
  for k in range(0,3):
    for l in range(0,3):
      if A[k][l] == i:
        A[k][l] = 0

if sum(A[0]) == 0:
  print('Yes')
  exit()
if sum(A[1]) == 0:
  print('Yes')
  exit()
if sum(A[2]) == 0:
  print('Yes')
  exit()

sum = 0
for i in range(0,3):
    sum+= A[i][0]
if sum == 0:
  print('Yes')
  exit()

sum = 0
for i in range(0,3):
    sum+= A[i][1]
if sum == 0:
  print('Yes')
  exit()

sum = 0
for i in range(0,3):
    sum+= A[i][2]
if sum == 0:
  print('Yes')
  exit()

if (A[0][0] + A[1][1] + A[2][2]) == 0:
  print('Yes')
  exit()
  
if (A[0][2] + A[1][1] + A[2][0]) == 0:
  print('Yes')
  exit()

print('No')

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

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

mask = [[0 for _ in range(3)] for _ in range(3)]
for row_idx, row in enumerate(A):
  for column_idx, element in enumerate(row):
    for val in b:
      if element == val:
        mask[row_idx][column_idx] = 1
        break

ans = "No"
for row in mask:
  if sum(row)==3: ans="Yes"
for column_idx in range(3):
  if mask[0][column_idx] + mask[1][column_idx] + mask[2][column_idx] == 3: ans="Yes"
if mask[0][0] + mask[1][1] + mask[2][2] == 3: ans="Yes"
if mask[0][2] + mask[1][1] + mask[2][0] == 3: ans="Yes"
print(ans)

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

t=[]
for i in range(n):
  b=int(input())
  for j in range(9):
    if b==s[j]:
      t.append(b)
      
def f(blist):
  for i in blist:
    if s[i] not in t:
      return False
  return True

p=[
[0,1,2],[3,4,5],[6,7,8],
  [0,3,6],
  [1,4,7],
  [2,5,8],
  [0,4,8],
  [2,4,6],
]
ans="No"
for i in p:
  if f(i):
    ans="Yes"
print(ans)

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

Solution (Python):
a = [input().split() for i in range(3)]
n = int(input())
b = [input() for i in range(n)]
for i in range(len(a)):
  for j in range(len(a[i])):
    for k in b:
      if int(a[i][j]) == int(k):
        a[i][j] = 0
if a[0][0] == 0 and a[0][1] == 0 and a[0][2] == 0 :
   print("Yes")
elif a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0 :
   print("Yes")
elif a[1][0] == 0 and a[1][1] == 0 and a[1][2] == 0 :
   print("Yes")
elif a[2][0] == 0 and a[2][1] == 0 and a[2][2] == 0 :
   print("Yes")
elif a[0][0] == 0 and a[1][0] == 0 and a[2][0] == 0 :
   print("Yes")
elif a[0][1] == 0 and a[1][1] == 0 and a[2][1] == 0 :
   print("Yes")
elif a[0][2] == 0 and a[1][2] == 0 and a[2][2] == 0 :
   print("Yes")
elif a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0 :
   print("Yes")
else:
   print("No")

Solution (Python):
A = []
B = [[0,0,0], [0,0,0], [0,0,0]]
for i in range(3):
  A.append(input().split())
  
N = int(input())
b = []
for i in range(N):
  b.append(int(input()))
  
for i in range(3):
  for j in range(3):
    if int(A[i][j]) in b:
      B[i][j] = 1

bingo = False
if B[0][0] and B[0][1] and B[0][2]:
  bingo = True
if B[1][0] and B[1][1] and B[1][2]:
  bingo = True
if B[2][0] and B[2][1] and B[2][2]:
  bingo = True
if B[0][0] and B[1][0] and B[2][0]:
  bingo = True
if B[0][1] and B[1][1] and B[2][1]:
  bingo = True
if B[0][2] and B[1][2] and B[2][2]:
  bingo = True
if B[0][0] and B[1][1] and B[2][2]:
  bingo = True
if B[0][2] and B[1][1] and B[2][0]:
  bingo = True
  
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()))
n = int(input())
for _ in range(n):
    b = int(input())
    if b in a1:
        a1[a1.index(b)] = 0
    elif b in a2:
        a2[a2.index(b)] = 0
    elif b in a3:
        a3[a3.index(b)] = 0

msg='No'

if a1[0] == 0:
    if a1[1] == 0:
        if a1[2] == 0:
            msg='Yes'
    if a2[0] == 0:
        if a3[0] == 0:
            msg='Yes'
    if a2[1] == 0:
        if a3[2] == 0:
            msg='Yes'
if 0 == a1[1] == a2[1] == a3[1]:
    msg='Yes'
if 0 == a1[2] == a2[2] == a3[2]:
    msg='Yes'
if 0 == a2[0] == a2[1] == a2[2]:
    msg='Yes'
if 0 == a3[0] == a3[1] == a3[2]:
    msg='Yes'
if 0 == a1[2] == a2[1] == a3[0]:
    msg='Yes'
print(msg)

Solution (Python):
A = []
flag = False
for i in range(3):
    a = list(map(int, input().split()))
    A.append(a)
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if b == A[j][k]:
                A[j][k] = 0
                
for i in range(3):
    if A[0][i]+A[1][i]+A[2][i]==0:
        flag = True
    

if sum(A[0])==0 or sum(A[1])==0 or sum(A[2])==0 or A[0][0]+A[1][1]+A[2][2]==0 or A[0][2]+A[1][1]+A[2][0]==0:
    flag = True

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

Solution (Python):
A = []

for i in range(3):
    temp = list(map(int, input().rstrip().split(' ')))
    A.append(temp)

N = int(input())

bingo = [[0] * 3 for i in range(3)]
for i in range(N):
    b = int(input())
    for y, row in enumerate(A):
        try:
            pos = (y, row.index(b))
            break
        except ValueError:
            pass

    try:
        bingo[pos[0]][pos[1]] = 1
    except:
        pass

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

Solution (Python):
import numpy as np

a=[]

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

a=np.array(a)

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:
                a[j][k]=-1
                break

bingo=False
for r in range(3):
    if np.all(a[r,:]==-1):
        bingo=True
        

for c in range(3):
    if np.all(a[:,c]==-1):
        bingo=True

if a[0][0]==-1 and a[1][1]==-1 and a[2][2]==-1:
    bingo=True

if a[0][2]==-1 and a[1][1]==-1 and a[2][0]==-1:
    bingo=True

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

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

tmp = []

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:
                tmp.append((j,k))

ans = [[(0,0),(1,1),(2,2)],[(0,2),(1,1),(2,0)],[(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)]]

for i in ans:
    count = 0
    for j in tmp:
        if j in i:
            count += 1
    if count == 3:
        print('Yes')
        exit()
print('No')

Solution (Python):

from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

card=[list(map(int, input().split())) for i in range(3)]
N=int(input())
num=[int(input()) for i in range(N)]
for i in range(3):
    for j in range(3):
        if card[i][j] in num:
            card[i][j] = True
        else:
            card[i][j] = False

res = 'No'
for i in range(3):
    if all(card[i]):
        res = 'Yes'
    if card[0][i] == card[1][i] == card[2][i] == True:
        res = 'Yes'

if card[0][0] == card[1][1] == card[2][2] == True:
    res = 'Yes'
elif card[0][2] == card[1][1] == card[2][0] == True:
    res = 'Yes'
print(res)