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=[list(map(int,list(input().split()))) for _ in range(3)]
b=[[0]*3 for _ in range(3)] 
n = int(input())

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

ans = False

for i in range(3):
  cnt = 0
  for j in range(3):
    cnt += b[i][j]
    if cnt == 3:
      ans = True

for i in range(3):
  cnt = 0
  for j in range(3):
    cnt += b[j][i]
    if cnt == 3:
      ans = True

cnt = 0
for j in range(3):
  cnt += b[j][j]
  if cnt == 3:
    ans = True

cnt = 0
for j in range(3):
  cnt += b[j][2-j]
  if cnt == 3:
    ans = True

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

Solution (Python):
A = [None for i in range(101)]  
row = [None, 0, 0, 0]
col = [None, 0, 0, 0]
cross = [None, 0, None, 0]
is_bingo = False


def solve(n):
    global is_bingo
    if is_bingo:
        return
    
    if A[n] is None:
        return
    idx = int(A[n])
    i = int(idx / 10)
    j = int(idx % 10)
    row[i] += 1
    col[j] += 1
    if i == j and i + j == 4:
        cross[1] += 1
        cross[3] += 1
    elif i == j and i + j != 4:
        cross[1] += 1
    elif i != j and i + j == 4:
        cross[3] += 1

    if row[i] == 3 or col[j] == 3 or cross[1] == 3 or cross[3] == 3:
        is_bingo = True



if __name__ == '__main__':
    idx = [int(i) for i in input().split(' ')]
    A[idx[0]] = '11'
    A[idx[1]] = '12'
    A[idx[2]] = '13'
    idx = [int(i) for i in input().split(' ')]
    A[idx[0]] = '21'
    A[idx[1]] = '22'
    A[idx[2]] = '23'
    idx = [int(i) for i in input().split(' ')]
    A[idx[0]] = '31'
    A[idx[1]] = '32'
    A[idx[2]] = '33'
    n = int(input())
    for i in range(0, n):
        solve(int(input()))
    if is_bingo:
        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())
B = [int(input()) for _ in range(N)]

if (A11 in B and A12 in B and A13 in B) or \
    (A21 in B and A22 in B and A23 in B) or \
    (A31 in B and A32 in B and A33 in B) or \
    (A11 in B and A21 in B and A31 in B) or \
    (A12 in B and A22 in B and A32 in B) or \
    (A13 in B and A23 in B and A33 in B) or \
    (A11 in B and A22 in B and A33 in B) or \
        (A13 in B and A22 in B and A31 in B):
    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)]
if (
       (A[0][0] in B and A[0][1] in B and A[0][2] in B)
    or (A[1][0] in B and A[1][1] in B and A[1][2] in B)
    or (A[2][0] in B and A[2][1] in B and A[2][2] in B)
    or (A[0][0] in B and A[1][0] in B and A[2][0] in B)
    or (A[0][1] in B and A[1][1] in B and A[2][1] in B)
    or (A[0][2] in B and A[1][2] in B and A[2][2] in B)
    or (A[0][0] in B and A[1][1] in B and A[2][2] in B)
    or (A[0][2] in B and A[1][1] in B and A[2][0] in B)
    ):
    print("Yes")
else:
    print("No")

Solution (Python):
A = [
    list(map(int, input().split())),
    list(map(int, input().split())),
    list(map(int, input().split()))
]
N = int(input())
B = list()
for i in range(N):
    B.append(int(input()))
if ((A[0][0] in B and A[0][1] in B and A[0][2] in B)
    or (A[1][0] in B and A[1][1] in B and A[1][2] in B)
    or (A[2][0] in B and A[2][1] in B and A[2][2] in B)
    or (A[0][0] in B and A[1][0] in B and A[2][0] in B)
    or (A[0][1] in B and A[1][1] in B and A[2][1] in B)
    or (A[0][2] in B and A[1][2] in B and A[2][2] in B)
    or (A[0][0] in B and A[1][1] in B and A[2][2] in B)
    or (A[0][2] in B and A[1][1] in B and A[2][0] in B)):
    print("Yes")
else:
    print("No")

Solution (Python):
A = [
    list(map(int, input().split())),
    list(map(int, input().split())),
    list(map(int, input().split()))
]
N = int(input())
B = [int(input()) for i in range(N)]
if ((A[0][0] in B and A[0][1] in B and A[0][2] in B)
    or (A[1][0] in B and A[1][1] in B and A[1][2] in B)
    or (A[2][0] in B and A[2][1] in B and A[2][2] in B)
    or (A[0][0] in B and A[1][0] in B and A[2][0] in B)
    or (A[0][1] in B and A[1][1] in B and A[2][1] in B)
    or (A[0][2] in B and A[1][2] in B and A[2][2] in B)
    or (A[0][0] in B and A[1][1] in B and A[2][2] in B)
    or (A[0][2] in B and A[1][1] in B and A[2][0] in B)):
    print("Yes")
else:
    print("No")

Solution (Python):
A = [
    list(map(int, input().split())),
    list(map(int, input().split())),
    list(map(int, input().split()))
]
N = int(input())
B = list()
for i in range(N):
    B.append(int(input()))
hantei_1 =False
hantei_2 =False
hantei_3 =False
hantei_4 =False
hantei_5 =False
hantei_6 =False
hantei_7 =False
hantei_8 =False
if A[0][0] in B and A[0][1] in B and A[0][2] in B:
    hantei_1 = True
if A[1][0] in B and A[1][1] in B and A[1][2] in B:
    hantei_2 = True
if A[2][0] in B and A[2][1] in B and A[2][2] in B:
    hantei_3 = True
if A[0][0] in B and A[1][0] in B and A[2][0] in B:
    hantei_4 = True
if A[0][1] in B and A[1][1] in B and A[2][1] in B:
    hantei_5 = True
if A[0][2] in B and A[1][2] in B and A[2][2] in B:
    hantei_6 = True
if A[0][0] in B and A[1][1] in B and A[2][2] in B:
    hantei_7 = True
if A[0][2] in B and A[1][1] in B and A[2][0] in B:
    hantei_8 = True
if hantei_1 or hantei_2 or hantei_3 or hantei_4 or hantei_5 or hantei_6 or hantei_7 or hantei_8:
    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)]

lines=[set(x) for x in a]+[set(x) for x in zip(*a)]+[set([a[0][0],a[1][1],a[2][2]])]+[set([a[0][2],a[1][1],a[2][0]])]

bs=set(b)
if any(line.issubset(bs) for line in lines):
    print("Yes")
else:
    print("No")

Solution (Python):

"""
Created on Tue Mar  3 22:38:51 2020

@author: Kanaru Sato
"""

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

N = int(input())

b = []
[b.append(int(input())) for i in range(0,N)]

flag = [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]]

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

column = 0
raw = 0
naname = 0

for i in range(0,3):
    column += flag[i][0]*flag[i][1]*flag[i][2]
    raw += flag[0][i]*flag[1][i]*flag[2][i]
naname = flag[0][0]*flag[1][1]*flag[2][2]+flag[0][2]*flag[1][1]*flag[2][0]


if column>=1 or raw>=1 or naname>=1:
    print("Yes")
else:
    print("No")

Solution (Python):
line1 = list(map(int,input().split()) )
line2 = list(map(int,input().split()))
line3 = list(map(int,input().split()))

N = int(input())
num = []
for _ in range(N):
    num.append(int(input()))
card = line1 + line2 + line3
result = []
for i in card:
    if i in num:
        result.append(1)
    else:
        result.append(0)
count = 0


for i in range(0,7,3):
    if result[i] == 1 and result[i + 1] == 1 and result[i + 2] == 1:
        count = 1
        print("Yes")
        break
if count == 0:
    for i in range(3):
        if result[i] == 1 and result[i+3] == 1 and result[i+6] == 1:
            count = 1
            print("Yes")
            break
if count == 0:
    if result[0] == result[4] == result[8] == 1:
        count = 1
        print("Yes")
        
if count == 0:
    if result[2] == result[4] == result[6] == 1:
        print('Yes')
    else:
        print('No')

Solution (Python):
import sys
A=[]
for a in range(3):
    l=[int(i) for i in input().split()]
    A.extend(l)
f=[0]*9
for i in range(int(input())):
    b=int(input())
    if b in A:
        f[A.index(b)]=1

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]]
for i in p:
    if all(f[x]==1 for x in i):
        print("Yes")
        sys.exit()
print("No")

Solution (Python):
li_a = list(input().split())
li_a += list(input().split())
li_a += list(input().split())
n = int(input())

for i in range(n):
    b = input()
    if b in li_a:
        idx = li_a.index(b)
        li_a[idx] = "o"
if any(
    [all(a == "o" for a in li_a[:3]),
    all(a == "o" for a in li_a[3:6]),
    all(a == "o" for a in li_a[6:]),
    all(a == "o" for a in li_a[::3]),
    all(a == "o" for a in li_a[1::3]),
    all(a == "o" for a in li_a[2::3]),
    all(a == "o" for a in li_a[::4]),
    all(a == "o" for a in li_a[2:8:2])]
    ):
    print("Yes")
else:
    print("No")

Solution (Python):
bingo = []
for i in range(3):
    a, b, c = map(int,input().split())
    bingo.append(a)
    bingo.append(b)
    bingo.append(c)
N = int(input())
b= []
for i in range(N):
    b_ele = int(input())
    b.append(b_ele)
    if b_ele in bingo:
        ind = bingo.index(b_ele)
        bingo[ind] = None
ans = "No"

if (not bingo[0] and bingo[0] == bingo[1] and bingo[0] == bingo[2]):
    ans = "Yes"
elif (not bingo[3] and bingo[3] == bingo[4] and bingo[3] == bingo[5]):
    ans = "Yes"
elif (not bingo[6] and bingo[6] == bingo[7] and bingo[6] == bingo[8]):
    ans = "Yes"
elif (not bingo[0] and bingo[0] == bingo[3] and bingo[0] == bingo[6]):
    ans = "Yes"
elif (not bingo[1] and bingo[1] == bingo[4] and bingo[1] == bingo[7]):
    ans = "Yes"
elif (not bingo[2] and bingo[2] == bingo[5] and bingo[2] == bingo[8]):
    ans = "Yes"
elif (not bingo[0] and bingo[0] == bingo[4] and bingo[0] == bingo[8]):
    ans = "Yes"
elif (not bingo[2] and bingo[2] == bingo[4] and bingo[2] == bingo[6]):
    ans = "Yes"

print(ans)

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

N = int(input())

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

def num_check(num):
    for i in range(3):
        for j in range(3): 
            if A[i][j] == num:
                bingo[i][j] = True


for i in range(N):
    num = int(input())
    num_check(num)

bingo_check = False

for i in range(3):
    count = 0
    for j in range(3):
        count += bingo[i][j]
        if count == 3:
            bingo_check = True


for i in range(3):
    count = 0
    for j in range(3):
        count += bingo[j][i]
        if count == 3:
            bingo_check = True


count = 0
for i in range(3):
    count += bingo[i][i]
if count == 3:
    bingo_check = True

count = 0
for i in range(3):
    count += bingo[i][2-i]
if count == 3:
    bingo_check = True

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

Solution (Python):

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

N = int(input())
b_set = set()

for i in range(N):
    b_set.add(int(input()))
    
bingos = [[a_array[0][0],a_array[0][1],a_array[0][2]],
         [a_array[1][0],a_array[1][1],a_array[1][2]],
         [a_array[2][0],a_array[2][1],a_array[2][2]],
         [a_array[0][0],a_array[1][0],a_array[2][0]],
         [a_array[0][1],a_array[1][1],a_array[2][1]],
         [a_array[0][2],a_array[1][2],a_array[2][2]],
         [a_array[0][0],a_array[1][1],a_array[2][2]],
         [a_array[0][2],a_array[1][1],a_array[2][0]]]

for bingo in bingos:
    if bingo[0] in b_set and bingo[1] in b_set and bingo[2] in b_set:
        print("Yes")
        break
else:
    print("No")

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

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

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

  for j in range(3):
    for k in range(3):
      if A[j][k] == b:
        hit_flag[j][k] = True

res = 'No'
if hit_flag[0][0] + hit_flag[0][1] + hit_flag[0][2] == 3:
  res = 'Yes'
elif hit_flag[1][0] + hit_flag[1][1] + hit_flag[1][2] == 3:
  res = 'Yes'
elif hit_flag[2][0] + hit_flag[2][1] + hit_flag[2][2] == 3:
  res = 'Yes'
elif hit_flag[0][0] + hit_flag[1][0] + hit_flag[2][0] == 3:
  res = 'Yes'
elif hit_flag[0][1] + hit_flag[1][1] + hit_flag[2][1] == 3:
  res = 'Yes'
elif hit_flag[0][2] + hit_flag[1][2] + hit_flag[2][2] == 3:
  res = 'Yes'
elif hit_flag[0][0] + hit_flag[1][1] + hit_flag[2][2] == 3:
  res = 'Yes'
elif hit_flag[0][2] + hit_flag[1][1] + hit_flag[2][0] == 3:
  res = 'Yes'

print(res)

Solution (Python):

a=[[int(i) for i in input().split()] for _ in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
               a[j][k]=0
ans='No'
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]:
        ans='Yes'
    elif a[0][i]==a[1][i]==a[2][i]:
        ans='Yes'
    elif a[0][0]==a[1][1]==a[2][2]:
        ans='Yes'
    elif a[0][2]==a[1][1]==a[2][0]:
        ans='Yes'
print(ans)

Solution (Python):
import numpy as np

def run():
  A = [list(map(int, input().split())) for n in range(3)]
  A = np.array(A)
  N = int(input())
  for n in range(N):
    b = int(input())
    for i in range(3):
      for j in range(3):
        a = A[i][j]
        if a == b:
          A[i][j] = 0
  ans = 1
  left = 0
  right = 0
  for i in range(3):
    ans = min(ans, np.sum(A, axis=0)[i])
    ans = min(ans, np.sum(A, axis=1)[i])
    left += A[i][i]
    right += A[i][2-i]
  ans = min(ans, left, right)
  if ans == 0:
    print('Yes')
  else:
    print('No')
    

if __name__ == '__main__':
  run()

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

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

marked = [False]*9
for i in b:
    for ind, num in enumerate(a):
        if i==num:
            marked[ind] = True
            break

bingos = [
    (0,1), (3,1), (6,1), (0,3), (1,3), (2,3), (0,4), (2,2)
]

for start, step in bingos:
    for i in range(start, start+3*step, step):
        if not marked[i]:
            break
    else:
        print('Yes')
        break
else:
    print('No')

Solution (Python):

def func(a, i):
    return {a[0]:i, a[1]:i+1, a[2]:i+2}
A = {}
for i in range(3):
    A.update(func(input().split(), 3*i))
N = int(input())
b = [A.get(input(), -1) for _ in range(N)]
bingo = [[0, 1, 2], [3, 4, 5], [6, 7, 8],
         [0, 3, 6], [1, 4, 7], [2, 5, 8],
         [0, 4, 8], [2, 4, 6]]
for i in bingo:
    if set(i) <= set(b):
        print("Yes")
        break
else:
    print("No")

Solution (Python):
a1,a2,a3 = map(int, input().split())
a4,a5,a6 = map(int, input().split())
a7,a8,a9 = map(int, input().split())

n = int(input())

list = []

for i in range(n):
    list.append(int(input()))

if a1 in list:
    a1 = 0

if a2 in list:
    a2 = 0

if a3 in list:
    a3 = 0

if a4 in list:
    a4 = 0

if a5 in list:
    a5 = 0

if a6 in list:
    a6 = 0

if a7 in list:
    a7 = 0

if a8 in list:
    a8 = 0

if a9 in list:
    a9 = 0



if a1 == 0 and a2 == 0 and a3 == 0:
    print('Yes')
elif a4 == 0 and a5 == 0 and a6 == 0:
    print('Yes')
elif a7 == 0 and a8 == 0 and a9 == 0:
    print('Yes')
elif a1 == 0 and a4 == 0 and a7 == 0:
    print('Yes')
elif a2 == 0 and a5 == 0 and a8 == 0:
    print('Yes')
elif a3 == 0 and a6 == 0 and a9 == 0:
    print('Yes')
elif a1 == 0 and a5 == 0 and a9 == 0:
    print('Yes')
elif a3 == 0 and a5 == 0 and a7 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	a = [LIST() for _ in range(3)]
	n = INT()
	b = [INT() for _ in range(n)]

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

	line = [[a[0][0], a[0][1], a[0][2]],
			[a[1][0], a[1][1], a[1][2]],
			[a[2][0], a[2][1], a[2][2]],
			[a[0][0], a[1][0], a[2][0]],
			[a[0][1], a[1][1], a[2][1]],			
			[a[0][2], a[1][2], a[2][2]],
			[a[0][0], a[1][1], a[2][2]],
			[a[0][2], a[1][1], a[2][0]]]

	if [0, 0, 0] in line:
		print("Yes")
	else:
		print("No")

if __name__=='__main__':
    main()

Solution (Python):
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))

n = int(input())

a_1 = [a1[0], a2[0], a3[0]]
a_2 = [a1[1], a2[1], a3[1]]
a_3 = [a1[2], a2[2], a3[2]]

naname1 = [a1[0],a2[1],a3[2]]
naname2 = [a1[2],a2[1],a3[0]]

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

yes = False

for bar in [a1, a2, a3, a_1, a_2, a_3, naname1, naname2]:
    if set(bar) <= set(hit):
        print('Yes')
        yes = True
        break

if not yes:
    print('No')

Solution (Python):
def bingo():
    bingo = [list(map(int, input().split())) for _ in range(3)]
    N=int(input())
    b=[int(input()) for i in range(N)]
    list_open=[[0]*3 for i in range(3)]
    flag=False

    
    for i in range(3):
        for j in range(3):
            for k in range(N):
                if bingo[i][j]==b[k]:
                    list_open[i][j]=1
            
            
    
    for i in range(3):
        judge=0
        for j in range(3):
            judge+=list_open[i][j]
        if judge==3:
            flag=True
            break

    for i in range(3):
        judge=0
        for j in range(3):
            judge+=list_open[j][i]
        if judge==3:
            flag=True
            break

    judge=0
    for i in range(3):
        judge+=list_open[i][i]
    if judge==3:
        flag=True

    judge=0
    for i in range(3):
        judge+=list_open[i][2-i]
    if judge==3:
        flag=True

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

bingo()

Solution (Python):

v = []
m = [False for _ in range(9)]
for i in range(3):
    a, b, c = map(int, input().split())
    v += [a, b, c]

n = int(input())
for i in range(n):
    a = int(input())
    if a in v:
        m[v.index(a)] = True

def control():
    for i in range(3):
        if all(m[3*i:3*i+3]):
            return True
        if all(m[i::3]):
            return True

    if all(m[::4]) or all(m[2:8:2]):
        return True
    return False

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

Solution (Python):
import numpy as np
def main():
    a_list = np.array([list(map(int, input().split())) for _ in range(3)])
    n = int(input())
    b_list = [int(input()) for _ in range(n)]
    for b in b_list:
        tmp = np.argwhere(a_list == b).tolist()
        if tmp:
            a_list[tmp[0][0], tmp[0][1]] = 0
    for i in range(3):
        
        if all([a == 0 for a in a_list[i]]):
            print("Yes")
            return
    
    for i in range(3):
        if all([a_list[j][i] == 0 for j in range(3)]):
            print("Yes")
            return
    
    if a_list[0][0] == a_list[1][1] == a_list[2][2] == 0:
        print("Yes")
        return
    if a_list[0][2] == a_list[1][1] == a_list[2][0] == 0:
        print("Yes")
        return
    print("No")
main()

Solution (Python):
import numpy as np 
A = [list(map(int, input().split())) for i in range(3)] 
N = int(input()) 
B = [int(input()) for i in range(N)]
C = np.zeros((3,3))
for i in range(N):
    for j in range(3):
        for k in range(3):
            if A[j][k] == B[i]:
                C[j][k] = 1
                
frag = False
f3,f4 = 0,0
for j in range(3):
    f1,f2 = 0,0 
    for k in range(3):
        f1 += C[j][k]
        f2 += C[k][j]
    if f1 == 3 or f2 == 3:
        frag = True
        break 
    f3 += C[j][j] 
    f4 += C[j][2-j]
    
if f3 == 3 or f4 == 3:
    frag = True
    
if frag:
    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())

A1_ans = [0, 0, 0]
A2_ans = [0, 0, 0]
A3_ans = [0, 0, 0]

for i in range(N):
    b = int(input())
    for j in range(3):
        if A1[j] == b:
            A1_ans[j] = 1
    for j in range(3):
        if A2[j] == b:
            A2_ans[j] = 1
    for j in range(3):
        if A3[j] == b:
            A3_ans[j] = 1
            
flag = False
for i in range(3):
    if A1_ans[i] == 1 and A2_ans[i] == 1 and A3_ans[i] == 1:
        flag = True
if A1_ans[0] == 1 and A1_ans[1] == 1 and A1_ans[2] == 1:
    flag = True
if A2_ans[0] == 1 and A2_ans[1] == 1 and A2_ans[2] == 1:
    flag = True
if A3_ans[0] == 1 and A3_ans[1] == 1 and A3_ans[2] == 1:
    flag = True
if A1_ans[0] == 1 and A2_ans[1] == 1 and A3_ans[2] == 1:
    flag = True
if A1_ans[2] == 1 and A2_ans[1] == 1 and A3_ans[0] == 1:
    flag = True
    
if flag:
    print("Yes")
else:
    print("No")

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

A.extend([[A[s][h] for s in range(3)] for h in range(3)])
A.append([A[s][s] for s in range(3)])
A.append([A[s][2-s] for s in range(3)])

flag_out = False
for i in range(8):
  flag = True
  for j in range(3):
    flag = (A[i][j] in B) & flag
  if(flag==True):
    print("Yes")
    flag_out = True
    break
if(flag_out==False):
  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)]

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] == 0 and A[i][1] == 0 and A[i][2] == 0:
        ans = "Yes"
    elif A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        ans = "Yes"
    elif 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):
import math

a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
flag = [[False] * 3 for _ in range(3)]

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


for row in flag:
    if all(row): 
        """
        組み込み関数all()は、()の中のすべての要素がTrueならTrueを返す
        """
        print('Yes')
        exit()

for i in range(3):
    tmp = 0
    for j in range(3):
        if flag[j][i]:
            tmp += 1
    
    if tmp == 3:
        print('Yes')
        exit()

if flag[0][0] and flag[1][1] and flag[2][2]:
    print('Yes')
    exit()
if flag[0][2] and flag[1][1] and flag[2][0]:
    print('Yes')
    exit()
print('No')

Solution (Python):
def check(l):
    c0 = all(l[i] for i in range(0, 9, 3))
    c1 = all(l[i] for i in range(1, 9, 3))
    c2 = all(l[i] for i in range(2, 9, 3))
    r0 = all(l[i] for i in range(3))
    r1 = all(l[i] for i in range(3, 6))
    r2 = all(l[i] for i in range(6, 9))
    x0 = all(l[i] for i in [0, 4, 8])
    x1 = all(l[i] for i in [2, 4, 6])
    return c0 or c1 or c2 or r0 or r1 or r2 or x0 or x1


def solve(string):
    *anb,  = map(int, string.split())
    a, n, b = anb[:9], anb[9], anb[10:]
    return "Yes" if check([_a in b for _a in a]) else "No"


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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

c = [[a[0][0], a[1][0], a[2][0]]] + [[a[0][1], a[1][1], a[2][1]]] + [[a[0][2], a[1][2], a[2][2]]] + [[a[0][0], a[1][1], a[2][2]]] + [[a[0][2], a[1][1], a[2][0]]]  + a
ans = "No"
for i,n1 in enumerate(c):
    a1 = 0
    for k,n2 in enumerate(n1):
        for j in b:
            if n2 == j:
                a1 += 1
        if a1 == 3:
            ans = "Yes"
            break
    else:
        continue
    break

print(ans)

Solution (Python):
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
ans  = [[False]*3 for _ in range(3)]
result = 'No'
for i in range(3):
  for j in range(3):
    for k in b:
      if a[i][j] == k:
        ans[i][j] = True 
for i in ans:
    if all(i):
      result = 'Yes'
for i in range(3):
  cnt = 0
  for j in range(3):
    if ans[j][i]:
      cnt += 1
  if cnt == 3:
    result = 'Yes'
    break
if ans[0][0] and ans[1][1] and ans[2][2]:
  result = "Yes"
if ans[0][2] and ans[1][1] and ans[2][0]:
  result = "Yes"
print(result)

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

n = int(input())
li = []
for i in range(n):
    d = int(input())
    for j in range(3):
        for k in range(3):
            if d ==L[j][k]:
                L[j][k] = 0
for i in range(3):
    if not any((L[i][j] for j in range(3))):
        print("Yes")
        exit()
    if not any((L[j][i] for j in range(3))):
        print("Yes")
        exit()
if not any((L[i][2-i] for i in range(3))):
        print("Yes")
        exit()
if not any((L[i][i] for i in range(3))):
        print("Yes")
        exit()
print("No")

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
flag = [[False]*3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            flag[i][j] = True



for row in flag:
    if all(row):
        print('Yes')
        exit()

for i in range(3):
    tmp = 0
    for j in range(3):
        if flag[j][i]:
            tmp += 1
    if tmp == 3:
        print('Yes')
        exit()


if flag[0][0] and flag[1][1] and flag[2][2]:
    print('Yes')
    exit()
if flag[0][2] and flag[1][1] and flag[2][0]:
    print('Yes')
    exit()
print('No')

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

li = [[False]*3 for _ in range(3)]
ans = 'No'

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


for i in range(3):
    if False not in li[i]:
        ans = 'Yes'

for i in range(3):
    if all((li[j][i] == True for j in range(3))):
        ans = 'Yes'

for i in range(3):
    if all((li[i][i] == True for i in range(3))):
        ans = 'Yes'

for i in range(3):
    if all((li[i][2-i] == True for i in range(3))):
        ans = 'Yes'

print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from bisect import bisect_left
import sys,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a = [inpl() for i in range(3)]
c = [[False] * 3 for i in range(3)]
n = inp()
b = [inp() for i in range(n)]
for x in b:
    for i in range(3):
        for j in range(3):
            if x == a[i][j]:
                c[i][j] = True

res = False
for i in range(3):
    if c[i].count(True) == 3:
        res = True
for i in range(3):
    if c[0][i] == c[1][i] == c[2][i] == True:
        res = True
if c[0][2] == c[1][1] == c[2][0] == True or c[0][0] == c[1][1] == c[2][2] == True:
    res = True
print('Yes' if res else 'No')

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

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

for a in A:
    if all(s in B for s in a):
        print("Yes")
        exit()
A = [list(a) for a in zip(*A)]
for a in A:
    if all(s in B for s in a):
        print("Yes")
        exit()
C = [[A[0][0],A[1][1],A[2][2]],[A[0][2],A[1][1],A[2][0]]]
if any(all(s in B for s in c) for c in C):
    print("Yes")
    exit()
print("No")

Solution (Python):
def main():
    A = [list(map(int, input().split())) for i in range(3)]
    N = int(input())
    b = [int(input()) for i 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)
main()

Solution (Python):
bingo = [0]*3
for i in range(3):
  bingo[i] = [int(x) for x in input().split()]

bingo_check = [[False]*3 for i in range(3)]

n = int(input())
for i in range(n):
  key = int(input())
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == key:
        bingo_check[j][k] = True

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

Solution (Python):

ls_a = []
for i in range(3):
    ls_a.extend(list(map(int,input().split())))
n = int(input())
ls_b = [int(input()) for i in range(n)]

for i in range(9):
    if ls_a[i] in ls_b:
        ls_a[i] = 0

for i in range(3):
    if ls_a[i] == 0 and ls_a[i+3] == 0 and ls_a[i+6] == 0:
        print("Yes")
        exit()
    if ls_a[i*3] == 0 and ls_a[i*3+1] == 0 and ls_a[i*3+2] == 0:
        print("Yes")
        exit()
if ls_a[0] == 0 and ls_a[4] == 0 and ls_a[8] == 0:
    print("Yes")
    exit()
if ls_a[2] == 0 and ls_a[4] == 0 and ls_a[6] == 0:
    print("Yes")
    exit()
print("No")

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

for b in B:
  for i in range(3):
    for j in range(3):
      if A[i][j] == b:
        A[i][j] = 0
f = False
for i in range(3):
  s = 0
  for j in range(3):
    s += A[i][j]
  if s == 0:
    f = True
for i in range(3):
  s = 0
  for j in range(3):
    s += A[j][i]
  if s == 0:
    f = True
s = 0
for i in range(3):
  s += A[i][i]
if s == 0:
  f = True
s = 0
for i in range(3):
  s += A[i][2-i]
if s == 0:
  f = True
print('Yes' if f else 'No')