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 sys

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


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

for i,k,j in [[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[3,5,7]]:
    if a[i-1]==a[j-1]==a[k-1]==-1:
        print("Yes")
        sys.exit()
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 = []
for i in range(n):
  b.append(int(input()))

if (a11 in b) and (a12 in b) and (a13 in b):
  print('Yes')
  exit()
if (a21 in b) and (a22 in b) and (a23 in b):
  print('Yes')
  exit()
if (a31 in b) and (a32 in b) and (a33 in b):
  print('Yes')
  exit()
if (a11 in b) and (a21 in b) and (a31 in b):
  print('Yes')
  exit()
if (a12 in b) and (a22 in b) and (a32 in b):
  print('Yes')
  exit()
if (a13 in b) and (a23 in b) and (a33 in b):
  print('Yes')
  exit()
if (a11 in b) and (a22 in b) and (a33 in b):
  print('Yes')
  exit()
if (a13 in b) and (a22 in b) and (a31 in b):
  print('Yes')
  exit()
print('No')

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

hit = [[0]*3 for _ in range(3)]
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                hit[i][j] = 1

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

for i in range(3):
    if hit[0][i]*hit[1][i]*hit[2][i] == 1:
        print('Yes')
        exit()

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

print('No')

Solution (Python):
a = list()
ans = "No"
for i in range(3):
  a += list(map(int, input().split()))
n = int(input())
c = [int(input()) for i in range(n)]
b = [0] * 9
for i in c:
  for k,j in enumerate(a):
    if i == j:
      b[k] = 1
if b[0] and b[1] and b[2]:
  ans = "Yes"
if b[3] and b[4] and b[5]:
  ans = "Yes"
if b[6] and b[7] and b[8]:
  ans = "Yes"
if b[0] and b[3] and b[6]:
  ans = "Yes"
if b[1] and b[4] and b[7]:
  ans = "Yes"
if b[2] and b[5] and b[8]:
  ans = "Yes"
if b[0] and b[4] and b[8]:
  ans = "Yes"
if b[2] and b[4] and b[6]:
  ans = "Yes"
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 = 'No'
if A[0][0] in B and A[0][1] in B and A[0][2] in B:
    ans = 'Yes'
if A[1][0] in B and A[1][1] in B and A[1][2] in B:
    ans = 'Yes'
if A[2][0] in B and A[2][1] in B and A[2][2] in B:
    ans = 'Yes'
if A[0][0] in B and A[1][0] in B and A[2][0] in B:
    ans = 'Yes'
if A[0][1] in B and A[1][1] in B and A[2][1] in B:
    ans = 'Yes'
if A[0][2] in B and A[1][2] in B and A[2][2] in B:
    ans = 'Yes'
if A[0][0] in B and A[1][1] in B and A[2][2] in B:
    ans = 'Yes'
if A[2][0] in B and A[1][1] in B and A[0][2] in B:
    ans = 'Yes'
print(ans)

Solution (Python):
import sys
range = xrange
input = raw_input

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

C = [[False,False,False] 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
def bingo():
    print 'Yes'
    sys.exit()

for x in range(3):
    if all(C[x]):
        bingo()

for y in range(3):
    if all(C[x][y] for x in range(3)):
        bingo()

if all(C[x][x] for x in range(3)):
    bingo()

if all(C[x][~x] for x in range(3)):
    bingo()

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):
    if A[i][j] in B:
      A[i][j]=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:
    print('Yes')
    exit(0)
if A[0][0]+A[1][1]+A[2][2]==0 or A[0][2]+A[1][1]+A[2][0]==0:
    print('Yes')
    exit(0)
print('No')

Solution (Python):
import numpy as np


def main():
  a=np.zeros((3,3))

  d={}
  for i in range(3):
    a[i]=list(map(int, input().split()))
    for j in range(3):
      d[a[i,j]]=(i,j)
  N=int(input())
  b=[]
  for i in range(N):
    b=int(input())
    if b in d:
      a[d[b]]=1
      
  for i in range(3):
    if a[i].sum()==3:
      print('Yes')
      return
  for i in range(3):
    if a[:,i].sum()==3:
      print('Yes')
      return
  if a[0,0]+a[1,1]+a[2,2]==3:
    print('Yes')
    return
  if a[0,2]+a[1,1]+a[2,0]==3:
    print('Yes')
    return
  
  print('No')
  return
main()

Solution (Python):
bingo = [[int(c) for c 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 bingo[j][k] == b:
                bingo[j][k] = 0

for i in bingo:
    if sum(i) == 0:
        print('Yes')
        exit()

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


n1 = 0
n2 = 0
for i in range(3):
    n1 += bingo[i][i]
    n2 += bingo[i][2-i]
if n1 == 0 or n2 == 0:
    print('Yes')
    exit()

print('No')

Solution (Python):
bingo = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
num = [int(input()) for _ in range(n)]
ans = [[0]* 3 for _ in range(3)]
for x in num:
    for i, row in enumerate(bingo):
        for j, bn in enumerate(row):
            if bn == x:
                ans[i][j] = 1
w = "No"
for i in range(3):
    if ans[0][i] == ans[1][i] == ans[2][i] == 1:
        w = "Yes"
        break
for i in ans:
    if sum(i) == 3:
        w = "Yes"
        break

if ans[0][0] == ans[1][1] == ans[2][2] == 1:
    w = "Yes"

if ans[0][2] == ans[1][1] == ans[2][0] == 1:
    w = "Yes"

print(w)

Solution (Python):

import sys
input = sys.stdin.readline

a = []
for _ in range(3):
    line = [int(item) for item in input().split()]
    a += line

n = int(input())
ok = [False] * 9
for _ in range(n):
    b = int(input())
    for i in range(9):
        if a[i] == b:
            ok[i] = True

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

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    result_flag = False
    for i in range(3):
        if A[i][0] in b and A[i][1] in b and A[i][2] in b:
            result_flag = True
        if A[0][i] in b and A[1][i] in b and A[2][i] in b:
            result_flag = True
    if A[0][0] in b and A[1][1] in b and A[2][2] in b:
        result_flag = True
    if A[0][2] in b and A[1][1] in b and A[2][0] in b:
        result_flag = True

    if result_flag:
        print("Yes")
    else:
        print("No")
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = [
        [int(next(tokens)) for _ in range(3)] for _ in range(3)
    ]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)


if __name__ == "__main__":
    main()

Solution (Python):
card = [list(map(int, input().split())) for _ in range(3)]
used = [[False for _ in range(3)] for _ in range(3)]
n = int(input())
for _ in range(n):
	b = int(input())
	for i in range(3):
		for j in range(3):
			if card[i][j] == b:
				used[i][j] = True

ok = False
for i in range(3):
	if used[i][0] and used[i][1] and used[i][2]:
		ok = True
	if used[0][i] and used[1][i] and used[2][i]:
		ok = True
	if used[0][0] and used[1][1] and used[2][2]:
		ok = True
	if used[0][2] and used[1][1] and used[2][0]:
		ok = True
if ok:
	print("Yes")
else:
	print("No")

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

for b in B:
    for i, line in enumerate(A):
        for j, a in enumerate(line):
            if a == b:
                flag[i][j] = True


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

if (flag[0][0] and flag[1][1] and flag[2][2]) or(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)]
B = [[0]*3 for _ in range(3)]
bingo = set(int(input()) for _ in range(int(input())))
for i in range(3):
    for j in range(3):
        if A[i][j] in bingo:
            B[i][j] = 1

ans = "No"
for i in range(3):
    if sum(B[i]) == 3: ans = "Yes"

for j in range(3):
    if B[0][j] + B[1][j] + B[2][j] == 3:
        ans = "Yes"

if B[0][0] + B[1][1] + B[2][2] == 3:
    ans = "Yes"

if B[0][2] + B[1][1] + B[2][0] == 3:
    ans  = "Yes"

print(ans)

Solution (Python):



import numpy as np
from numpy import newaxis, float32, float64, int32, int64, int16, int8, uint8, uint32, complex64, complex128
import itertools



def getIntList(inp):
	return [int(_) for _ in inp]
	

from sys import stdin

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs

def v(on):
	for i in range(3):
		if on[i,:].all():
			return True
	for i in range(3):
		if on[:,i].all():
			return True
	
	if on[0,0] and on[1,1] and on[2,2]: return True
	if on[2,0] and on[1,1] and on[0,2]: return True
	return False

def main(inputs):
	a=np.empty((3,3),int32)
	aIndex={}
	on=np.zeros((3,3),np.bool)
	for i,j in itertools.product(range(3),range(3)):
		a[i,j]=int(inputs[i][j])
		aIndex[a[i,j]]=(i,j)
		
	n=int(inputs[3][0])
	for i in range(n):
		bi=int(inputs[i+4][0])
		if bi in aIndex:
			index=aIndex[bi]
			on[index[0],index[1]]=True
	
	vv=v(on)
	if vv: print("Yes")
	else: print("No")
	

if __name__=="__main__":
	inputs=getInputs()

	main(inputs)

Solution (Python):

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret

def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max,mod=DIV):
    fac,finv,inv = [0]*max, [0]*max, [0]*max
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod -inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    class CONV:
        def __init__(self):
            pass
        def ncr(self,n,k):
            if(n<k):
                return 0
            if(n<0 or k<0 ):
                return 0
            return fac[n]*(finv[k]*finv[n-k]%mod)%mod
    return CONV()


def main():
    As = [isRaw() for _ in range(3)]
    N = iRaw()
    bs = [iRaw() for _ in range(N)]
    for b in bs:
        for ridx,arow in enumerate(As):
            for cidx,a in enumerate(arow):
                if a==b:
                    As[ridx][cidx] = 0
    for ridx in range(3):
        if sum(As[ridx])==0:
            return "Yes"
        if sum([As[i][ridx] for i in range(3)])==0:
            return "Yes"
    if sum([As[i][i] for i in range(3)])==0:
        return "Yes"
    if sum([As[2-i][i] for i in range(3)])==0:
        return "Yes"
    return "No"
                    

if __name__ == "__main__":
    print(main())

Solution (Python):
l = [list(map(int,input().split())) for i in range(3)]
n = int(input())
a = []
for i in range(n):
    s = int(input())
    a.append(s)
ans = [[0]*3 for i in range(3)]

for j in range(3):
    for k in range(3):
        if l[j][k] in a:
            ans[j][k] = 1

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

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

N = int(input())
for k in range(N):
    t = int(input())
    for e in C:
        for l in range(3):
            if e[l] == t:
                e[l] = -1

f = 0
for e in C:
    if e == [-1,-1,-1]:
        f = 1
        break

for k in range(3):
    if C[0][k] == C[1][k] == C[2][k] == -1:
        f = 1
        break
if C[0][0] == C[1][1] == C[2][2] == -1:
    f = 1
if C[0][2] == C[1][1] == C[2][0] == -1:
    f = 1

print("Yes" if f == 1 else "No")

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

N = int(input())

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

    for i, row in enumerate(A):
        for j, a in enumerate(row):
            if a == b:
                A[i][j] = -1

for i in range(3):
    f = True
    for j in range(3):
        f &= A[i][j] == -1

    if f:
        print('Yes')
        exit()

for i in range(3):
    f = True
    for j in range(3):
        f &= A[j][i] == -1

    if f:
        print('Yes')
        exit()

f = True
for i in range(3):
    f &= A[i][i] == -1

if f:
    print('Yes')
    exit()

f = True
for i in range(3):
    f &= A[2-i][i] == -1

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

for i in range(3):
    for j in range(2):
        if A[i][j] != A[i][j+1]: break
    else:
        print('Yes')
        exit()

for j in range(3):
    for i in range(2):
        if A[i][j] != A[i+1][j]: break
    else:
        print('Yes')
        exit()

for i in range(2):
    if A[i][i] != A[i+1][i+1]: break
else:
    print('Yes')
    exit()

for i in range(2):
    if A[2-i][i] != A[1-i][i+1]: break
else:
    print('Yes')
    exit()

print('No')

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

for _ in range(N):
    b = int(input())
    for y in range(3):
        for x in range(3):
            if A[y][x] == b:
                A[y][x] = -1

for y in range(3):
    f = True
    for x in range(3):
        if A[y][x] != -1:
            f = False
    if f:
        print('Yes')
        exit()

for x in range(3):
    f = True
    for y in range(3):
        if A[y][x] != -1:
            f = False
    if f:
        print('Yes')
        exit()

f = True
for x in range(3):
    if A[x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()

f = True
for x in range(3):
    if A[2 - x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()

print('No')

Solution (Python):
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]=-1
ans="No"
for i in range(3):
    if A[i]==[-1,-1,-1]:
        ans="Yes"
for i in range(3):
    if A[0][i]==-1 and A[1][i]==-1 and A[2][i]==-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 i in range(3)]
N = int(input())
b = set([int(input()) for i in range(N)])
flag = False
for i in range(3):
  if A[i][0] in b and A[i][1] in b and A[i][2] in b:
    flag = True
  if A[0][i] in b and A[1][i] in b and A[2][i] in b:
    flag = True
if A[0][0] in b and A[1][1] in b and A[2][2] in b:
  flag = True
if A[0][2] in b and A[1][1] in b and A[2][0] in b:
  flag = True
print(['No','Yes'][flag])

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


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

N=int(input())
for i in range(N):
    n=int(input())
    for h in range(3):
        for w in range(3):
            if L[h][w]==n:
                B[h][w]=1

F=0
for h in range(3):
    cnt=0
    for w in range(3):
        cnt+=B[h][w]
    if cnt==3:
        F=1

for w in range(3):
    cnt=0
    for h in range(3):
        cnt+=B[h][w]
    if cnt==3:
        F=1

if B[0][0]+B[1][1]+B[2][2]==3:
    F=1
if B[2][0]+B[1][1]+B[0][2]==3:
    F=1
if F==1:
    print("Yes")
else:
    print("No")

Solution (Python):




def solve(inp):
    A = list(map(int, inp.readline().strip().split(' ')))
    A += list(map(int, inp.readline().strip().split(' ')))
    A += list(map(int, inp.readline().strip().split(' ')))
    N = int(inp.readline().strip())
    B = [int(inp.readline().strip()) for i in range(N)]

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

    for a, b, c in [
        [0, 1, 2],
        [3, 4, 5],
        [6, 7, 8],
        [0, 3, 6],
        [1, 4, 7],
        [2, 5, 8],
        [0, 4, 8],
        [2, 4, 6],
    ]:
        if A[a] == A[b] == A[c] == 0:
            return "Yes"

    return "No"


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()

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

t0 = [0,1,2,0,2]
t1 = [0,1,2,1,1]
t2 = [0,1,2,2,0]

bingo = False
for i in range(N):
    for h in range(3):
        for w in range(3):
            if a[h][w] == b[i]:
                a[h][w] = 0
    for t in range(5):
        if a[0][t0[t]]+a[1][t1[t]]+a[2][t2[t]] == 0:
            bingo = True
    for y in range(3):
        if sum(a[y]) ==0:
            bingo = True
    if bingo: break

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

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

bingo = [[0 for _ in range(3)] for _ in range(3)]

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

f = False
for i in range(3):
    f_tmp = True
    for j in range(3):
        if not(bingo[i][j] and f_tmp):
            f_tmp = False
    if f_tmp:
        f = True

for j in range(3):
    f_tmp = True
    for i in range(3):
        if not(bingo[i][j] and f_tmp):
            f_tmp = False
    if f_tmp:
        f = True

f_tmp = True
for i in range(3):
    if not(bingo[i][i] and f_tmp):
        f_tmp = False
if f_tmp:
    f = True

f_tmp = True
for i in range(3):
    if not(bingo[2-i][i] and f_tmp):
        f_tmp = False
if f_tmp:
    f = True

if f:
    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)]
hit = [[False] * 3 for _ in range(3)]

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

bingo = False

for i in range(3):
    if hit[0][i] and hit[1][i] and hit[2][i]:
        bingo = True
    elif hit[i][0] and hit[i][1] and hit[i][2]:
        bingo = True

if hit[0][0] and hit[1][1] and hit[2][2]:
    bingo = True
elif hit[0][2] and hit[1][1] and hit[2][0]:
    bingo = True

print("Yes" if bingo else "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)]

def ok(a, b, c):
    return B.__contains__(a) and B.__contains__(b) and B.__contains__(c)

print("Yes" if ok(a11, a12, a13) or ok(a21, a22, a23) or ok(a31, a32, a33) or ok(a11, a21, a31) or ok(a12, a22, a23) or ok(a13, a23, a33) or ok(a11, a22, a33) or ok(a13, a22, a31) else "No")

Solution (Python):

import sys
import numpy as np

YES = "Yes"  
NO = "No"  

def is_bingo(row, B):
    count = 0 
    for b in B:
        if b in row:
            count += 1
    if count >= 3:
        return True
    else:
        False

def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    A = np.asarray(A)
    isbingo = False

    for row in A:
        if is_bingo(row, b):
            isbingo = True

    for col in A.T:
        if is_bingo(col, b):
            isbingo = True

    for diag in [np.diag(A), np.diag(np.fliplr(A))]:
        if is_bingo(diag, b):
            isbingo = True

    if isbingo:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)

if __name__ == '__main__':
    main()

Solution (Python):
A = [[0 for _ in range(3)] for _ in range(3)]

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

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


flag = [[False for _ in range(3)] for _ in range(3)]

f = False
for b in B:
    for row in range(3):
        for col in range(3):
            if A[row][col] == b:
                flag[row][col] = True
                f = True
if not f:
    print("No")
    exit(0)
    

for row in range(3):
    f = True
    for col in range(3):
        if not flag[row][col]:
            f = False
            break
    if f:
        print("Yes")
        exit(0)


for row in range(3):
    f = True
    for col in range(3):
        if not flag[col][row]:
            f = False
            break
    if f:
        print("Yes")
        exit(0)


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

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

flag = False
for i in a:
    if sum(i) == 0:
        flag = True
if flag == False:
    for i in range(3):
        if a[0][i] + a[1][i] + a[2][i] == 0:
            flag = True
if flag == False:
    if a[0][0] + a[1][1] + a[2][2] == 0:
        flag = True
    if a[0][2] + a[1][1] + a[2][0] == 0:
        flag = True
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline

A = [list(map(int, readline().split())) for _ in range(3)]
N, *b = map(int, read().split())
b = set(b)

for i in A:
    for j in i:
        if j not in b:
            break
    else:
        print('Yes')
        exit()

for i in range(3):
    for j in range(3):
        if A[j][i] not in b:
            break
    else:
        print('Yes')
        exit()

c1 = [(0, 0), (1, 1), (2, 2)]
c2 = [(0, 2), (1, 1), (2, 0)]
for i, j in c1:
    if A[i][j] not in b:
        break
else:
    print('Yes')
    exit()

for i, j in c2:
    if A[i][j] not in b:
        break
else:
    print('Yes')
    exit()

print('No')

Solution (Python):
def check(card):
    for i in range(3):
        if all(card[i][j] == 'o' for j in range(3)):
            return True
    for j in range(3):
        if all(card[i][j] == 'o' for i in range(3)):
            return True
    if all(card[i][j] == 'o' for (i, j) in [(0, 0), (1, 1), (2, 2)]):
        return True
    if all(card[i][j] == 'o' for (i, j) in [(0, 2), (1, 1), (2, 0)]):
        return True
    return False


card = [[0] * 3 for _ in range(3)]
mapping = {}
for i in range(3):
    for j, x in enumerate(map(int, input().split())):
        card[i][j] = x
        mapping[x] = (i, j)
N = int(input())
for _ in range(N):
    y = int(input())
    if y in mapping:
        i, j = mapping[y]
        card[i][j] = 'o'

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

Solution (Python):
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def functional(N, mod):
    F = [1] * (N + 1)
    for i in range(N):
        F[i + 1] = (i + 1) * F[i] % mod
    return F


def main():
    A = []
    for _ in range(3):
        a = read_list()
        A.extend(a)
    N = int(input())
    B = [False] * 9
    for _ in range(N):
        b = int(input())
        if b in A:
            c = A.index(b)
            B[c] = True

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


if __name__ == "__main__":
    main()

Solution (Python):
A = [list(map(int,input().split())) for i in range(3)]
n = int(input())
B = [int(input()) for i in range(n)]
C = [[0] * 3 for i in range(3)]
for i in range(3):
    for j in range(3):
        for k in range(n):
            if A[i][j] == B[k] :
                C[i][j] += 1
y=0
for i in range(3):
    if sum(C[i]) == 3:
        y = 1
    if C[0][i] + C[1][i] + C[2][i] == 3:
        y = 1
if C[0][0] + C[1][1] + C[2][2] == 3:
    y = 1
if C[0][2] + C[1][1] + C[2][0] == 3:
    y = 1
if y == 1:
    print("Yes")
else:
    print("No")

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

for _ in range(N):
  b=int(input())
  for i in range(3):
    for j in range(3):
      if b==A[i][j]:
        C[i][j]=1

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

Solution (Python):
a = [list(map(int, input().split())) for i in range(3)]
f = [[False]*3 for i in range(3)]
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))
for y in range(3):
    for x in range(3):
        if a[y][x] in b:
            f[y][x] = True
for y in range(3):
    if f[y][0] and f[y][1] and f[y][2]:
        print("Yes")
        exit()
for x in range(3):
    if f[0][x] and f[1][x] and f[2][x]:
        print("Yes")
        exit()
if f[0][0] and f[1][1] and f[2][2]:
    print("Yes")
    exit()
if f[2][0] and f[1][1] and f[0][2]:
    print("Yes")
    exit()
print("No")

Solution (Python):
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left 


sys.setrecursionlimit(10**7)
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

chk = [[0] * 3 for _ in range(3)]

for bi in b:
    for i, row in enumerate(A):
        for j, col in enumerate(row):
            if col == bi:
                chk[i][j] = 1






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

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

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

    if chk[0][i] and chk[1][i] and chk[2][i]:
        print('Yes')
        exit()

print('No')

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

N = int(input())

flag = [[False]*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 b==A[j][k]:
                flag[j][k]=True

for i in range(3):
    ans = True
    for j in range(3):
        if not flag[i][j]:
            ans=False
            break
    if ans:
        print("Yes")
        break

if not ans:
    for i in range(3):
        ans = True
        for j in range(3):
            if not flag[j][i]:
                ans=False
                break
        if ans:
            print("Yes")
            break

if not ans:
    ans = True
    for i in range(3):
        if not flag[i][i]:
            ans = False
            break
    if ans:
        print("Yes")

if not ans:
    ans = True
    for i in range(3):
        if not flag[i][2-i]:
            ans = False
            break
    if ans:
        print("Yes")

if not ans:
    print("No")

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


n = int(input())
B = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(n):
    num = int(input())
    for j in range(3):
        for i in range(3):
            if A[j][i] == num:
                B[j][i] = 1

ans = 0
for i in B:
    if len(set(i)) == 1 and i[0] == 1:
        ans = 1
for j in range(3):
    if B[0][j] == 1 and B[1][j] == 1 and B[2][j] == 1:
        ans = 1
if B[0][0] == 1 and B[1][1] == 1 and B[2][2] == 1:
    ans = 1
if B[0][2] == 1 and B[1][1] == 1 and B[2][0] == 1:
    ans = 1

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