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):
K=[['x','x','x'],
   ['x','x','x'],
   ['x','x','x']]
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,j=map(int,input().split())
N=int(input())
B=[]
for _ in range(N):
    B.append(int(input()))

for i in range(N):
  if B[i]==a:
    K[0][0]='o'
  if B[i]==b:
    K[0][1]='o'
  if B[i]==c:
    K[0][2]='o'
  if B[i]==d:
    K[1][0]='o'
  if B[i]==e:
    K[1][1]='o'
  if B[i]==f:
    K[1][2]='o'
  if B[i]==g:
    K[2][0]='o'
  if B[i]==h:
    K[2][1]='o'
  if B[i]==j:
    K[2][2]='o'

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

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

n = int(input())

for i in range(n):
    nn = int(input())
    for j in range(3):
        for k in range(3):
            if ll[j][k] == nn:
                ll[j][k] = "

flag = False
for i in range(3):
    if ll[i][0] == "
        flag = True
        break
    elif ll[0][i] == "
        flag = True
        break
if ll[0][0] == "
    flag = True
elif ll[0][2] == "
    flag = True

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

Solution (Python):
a1 = input().split()
a2 = input().split()
a3 = input().split()
n = int(input())
ans = "No"
x = [0] * 9
for i in range(n):
    b = input()
    if b in a1:
        x[a1.index(b)] = 1
    if b in a2:
        x[a2.index(b)+3] = 1
    if b in a3:
        x[a3.index(b)+6] = 1

if x[0]+x[1]+x[2]==3 or x[3]+x[4]+x[5]==3 or x[6]+x[7]+x[8]==3 or x[0]+x[3]+x[6]==3 or x[1]+x[4]+x[7]==3 or x[2]+x[5]+x[8]==3 or x[0] + x[4] + x[8] == 3 or x[2]+x[4]+x[6]==3:
    ans = "Yes"
    
print(ans)

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
a = a[0] + a[1] + a[2]
c = [
        a[0:3], a[3:6], a[6:9], a[::3], a[1::3], a[2::3],
        [a[0], a[4], a[8]], [a[2], a[4], a[6]]
    ]
n = int(input())
b = [int(input()) for _ in range(n)]


same = set(a) & set(b)

for d in c:
    cnt = 0
    for n in same:
        if n in d:
            cnt += 1
    if cnt == 3:
        print("Yes")
        exit()
else:
    print("No")

Solution (Python):
card = [list(map(int, input().split())) for i in range(3)]
n = int(input())
chk = [[0] * 3 for i in range(3)]

for i in range(n):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if num == card[j][k]:
                chk[j][k] = 1

if any([all([chk[0][0], chk[0][1], chk[0][2]]),
        all([chk[1][0], chk[1][1], chk[1][2]]),
        all([chk[2][0], chk[2][1], chk[2][2]]),
        all([chk[0][0], chk[1][0], chk[2][0]]),
        all([chk[0][1], chk[1][1], chk[2][1]]),
        all([chk[0][2], chk[1][2], chk[2][2]]),
        all([chk[0][0], chk[1][1], chk[2][2]]),
        all([chk[0][2], chk[1][1], chk[2][0]])
        ]):
    print("Yes")
else:
    print("No")

Solution (Python):

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

    n = int(input())
    exsit = [int(input()) for i in range(n)]
    for e in exsit:
        for b in bingo:
            if b.count(e) == 1:
                b[b.index(e)] = 0
    naname = [0, 0]
    for i in range(len(bingo)):
        if bingo[i].count(0) == 3:
            print('Yes')
            exit()
        elif [bingo[j][i] for j in range(3)].count(0) == 3:
            print('Yes')
            exit()
        naname[0] += 1 if bingo[i][i] == 0 else 0
        naname[1] += 1 if bingo[i][2 - i] == 0 else 0

    if naname[0] == 3 or naname[1] == 3:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()

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

def popcount(n):
    return bin(n).count('1')
ans = False
a = sum(a,[])
abingo = 0
for i in b:
    if i in a:
        abingo |= 256>>(a.index(i))
virtical = 0b100100100
side = 0b111000000
downleft = 0b001010100
downright = 0b100010001
for i in range(3):
    if popcount(abingo & virtical)==3: ans=True
    if popcount(abingo & side)==3: ans=True
    virtical >>= 1
    side >>= 3
if popcount(abingo & downleft)==3: ans=True
if popcount(abingo & downright)==3: ans=True

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

Solution (Python):
card = []

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

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


print('No')

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

Solution (Python):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
n = int(input())
a = []
ans = 0
for i in range(n):
    b = int(input()) 
    a.append(b)
for i in range(3):
    if a1[i] in a and a2[i] in a and a3[i] in a:
        ans = 'Yes'
if a1[0] in a and a1[1] in a and a1[2] in a:
    ans = 'Yes'
if a2[0] in a and a2[1] in a and a3[2] in a:
    ans = 'Yes'
if a3[0] in a and a3[1] in a and a3[2] in a:
    ans = 'Yes'
if a1[0] in a and a2[1] in a and a3[2] in a:
    ans = 'Yes'
if a1[2] in a and a2[1] in a and a3[0] in a:
    ans = 'Yes'
if ans == 'Yes':
    print(ans)
else:
    print('No')

Solution (Python):
A = []
 
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
b = []
for i in range(N):
    b.append(int(input()))
 
for i in range(3):
    if A[i][0] in b and A[i][1] in b and A[i][2] in b:
        print('Yes')
        exit()
for i in range(3):
    if A[0][i] in b and A[1][i] in b and A[2][i] in b:
        print('Yes')
        exit()
if A[0][0] in b and A[1][1] in b and A[2][2] in b:
    print('Yes')
    exit()
if A[2][0] in b and A[1][1] in b and A[0][2] in b:
    print('Yes')
    exit()
 
 
 
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())

la = list()
la.append(a1)
la.append(a2)
la.append(a3)
la.append(a4)
la.append(a5)
la.append(a6)
la.append(a7)
la.append(a8)
la.append(a9)

N = int(input())

lb = list()
for i in range(N):
    lb.append(int(input()))

for i in range(N):
    for j in range(9):
        if lb[i] == la[j]:
            la[j] = 0

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

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

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

check = "No"

for j in range(3):
    if n[j + 0] == 0 and n[j + 3] == 0 and n[j + 6] == 0:
        check = "Yes"
        break
    if n[j * 3] == 0 and n[j * 3 + 1] == 0 and n[j * 3 + 2] == 0:
        check = "Yes"
        break

if n[0] == 0 and n[4] == 0 and n[8] == 0:
        check = "Yes"
if n[2] == 0 and n[4] == 0 and n[6] == 0:
        check = "Yes"

print(check)

Solution (Python):
def main():
    A = [[int(a) for a in input().split()] for i in range(3)]
    N = int(input())
    b = [int(input()) for i 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] = "x"
    bingo = False
    if A[0][0] == A[0][1] == A[0][2] == "x" or \
       A[1][0] == A[1][1] == A[1][2] == "x" or \
       A[2][0] == A[2][1] == A[2][2] == "x" or \
       A[0][0] == A[1][0] == A[2][0] == "x" or \
       A[0][1] == A[1][1] == A[2][1] == "x" or \
       A[0][2] == A[1][2] == A[2][2] == "x" or \
       A[0][0] == A[1][1] == A[2][2] == "x" or \
       A[0][2] == A[1][1] == A[2][0] == "x":
       bingo = True
       
    if bingo:
        print("Yes")
    else:
        print("No")
main()

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 n in range(N):
    B.append(int(input()))
ans='No'

def judge(A, B):
    for i in range(3): 
        if A[i] in B:
            A[i] = 1
        else:
            A[i] = 0

judge(A1, B)
judge(A2, B)
judge(A3, B)

if sum(A1)==3 or sum(A2)==3 or sum(A3)==3:
    ans = 'Yes' 
for i in range(3):
    if A1[i] + A2[i] + A3[i] == 3:
        ans = 'Yes'
if A1[0] + A2[1] + A3[2] == 3 or A1[2] + A2[1] + A3[0] == 3:
    ans = 'Yes'

print(ans)

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

Solution (Python):
a_1=list(map(int, input().split()))
a_2=list(map(int, input().split()))
a_3=list(map(int, input().split()))

c=[a_1,a_2,a_3]

N=int(input())

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

for i in range(3):
    for j in range(3):
        if c[i][j] in b:
            c[i][j]=0
            
            
i=0
if c[0][0]==0 and c[0][1]==0 and c[0][2]==0:
    i+=1
if c[1][0]==0 and c[1][1]==0 and c[1][2]==0:
    i+=1
if c[2][0]==0 and c[2][1]==0 and c[2][2]==0:
    i+=1
if c[0][0]==0 and c[1][0]==0 and c[2][0]==0:
    i+=1
if c[0][1]==0 and c[1][1]==0 and c[2][1]==0:
    i+=1
if c[0][2]==0 and c[1][2]==0 and c[2][2]==0:
    i+=1
if c[0][0]==0 and c[1][1]==0 and c[2][2]==0:
    i+=1
if c[0][2]==0 and c[1][1]==0 and c[2][0]==0:
    i+=1
    
if i>0:
    print("Yes")
else:
  print("No")

Solution (Python):
a_list = []
a_result = []
b_list = []
for i in range(3):
    a_list.append(list(map(int,input().split())))
    a_result.append([0,0,0])
n = int(input())
for i in range(n):
    b_list.append(int(input()))

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a_list[i][j] == b_list[k]:
                a_result[i][j] = 1
                break

judge = 'No'
for i in range(3):
    if a_result[i][0]*a_result[i][1]*a_result[i][2] == 1:
        judge = 'Yes'
for j in range(3):
    if a_result[0][j]*a_result[1][j]*a_result[2][j] == 1:
        judge = 'Yes'
if a_result[0][0]*a_result[1][1]*a_result[2][2] == 1:
    judge = 'Yes'
if a_result[0][2]*a_result[1][1]*a_result[2][0] == 1:
    judge = 'Yes'

print(judge)

Solution (Python):
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)


args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])



def main():
    A = input([[int, 3], 3])
    N = input(int)
    B = input([int, N])

    ans = 0
    for x in range(3):
        for y in range(3):
            if A[x][y] not in B:
                break
        else:
            ans += 1
    for y in range(3):
        for x in range(3):
            if A[x][y] not in B:
                break
        else:
            ans += 1
    for z in range(3):
        if A[z][z] not in B:
            break
    else:
        ans += 1
    for z in range(3):
        if A[z][2 - z] not in B:
            break
    else:
        ans += 1
    yesno(not ans == 0)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

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

n = int(input())

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

Solution (Python):
a=[list(map(int,input().split()))for _ in range(3)]
N = int(input())
for i in range(N):
  b=int(input())
  for j in range(3):
    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]==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[2][0]==a[1][1]==a[0][2]==0:
    ans="Yes"
print(ans)

Solution (Python):

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

mark = [[0]*3, [0]*3, [0]*3]

for i in range(N):
    b = int(input())
    for j, a in enumerate(A):
        for k, aa in enumerate(a):
            if aa == b:
                mark[j][k] = 1


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

print("No")

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

alinelist = []
for i in range(1, 4):
  for j in range(1, 4):
    alinelist.append(alist[i - 1][j - 1])

n = int(input())

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

bhitlist = []
for k in blist:
  if str(k) in alinelist:
    hitindex = alinelist.index(str(k))
    bhitlist.append(hitindex)

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

bingoflag = False
for m in correctlist:
  bingocount = 0
  for n in m:
    if (n in bhitlist):
      bingocount += 1
    else:
      bingocount = 0
  if bingocount == 3:
    bingoflag = True
    break
  else:
        continue
  break

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

Solution (Python):

def main():
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    A = [a,b,c]
    n = int(input())
    B = []
    C = []
    for i in range(n):
        B.append(int(input()))
    for i in range(3):
        for j in range(3):
            if A[i][j] in B:
                C.append(i*10 + j)
    D = []
    if 0 in C:
        D += [1,4,7]
    if 1 in C:
        D += [1,5]
    if 2 in C:
        D += [1,6,8]
    if 10 in C:
        D += [2,4]
    if 11 in C:
        D += [2,5,7,8]
    if 12 in C:
        D += [2,6]
    if 20 in C:
        D += [3,4,8]
    if 21 in C:
        D += [3,5]
    if 22 in C:
        D += [3,6,7]
    for i in range(1,9):
        if D.count(i) == 3:
            print("Yes")
            quit()
    print("No")
    

if __name__ == '__main__':
    main()

Solution (Python):


import sys



















def main():
    mod = 1000000007                  
    inf = float('inf')
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    L = []
    res = [[False] * 3 for _ in range(3)]
    for _ in range(3):
        L.append(lmi())
    n = ii()
    for _ in range(n):
        num = ii()
        for i in range(3):
            for j in range(3):
                if L[i][j] == num:
                    res[i][j] = True
    
    trans = [[None] * 3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            trans[j][i] = res[i][j]
    print('Yes') if any(map(all, (res[0], res[1], res[2], trans[0], trans[1], trans[2], [res[0][0], res[1][1], res[2][2]], [res[0][2], res[1][1], res[2][0]]))) else print('No')


if __name__ == "__main__":
    main()

Solution (Python):
bingo1 = list(map(int,input().split()))
bingo2 = list(map(int,input().split()))
bingo3 = list(map(int,input().split()))

bingo_list = []
bingo_list.append(bingo1)
bingo_list.append(bingo2)
bingo_list.append(bingo3)
N = int(input())

bingo_flag = False

for i in range(N):
    b = int(input())
    for j in range(3):
        if b in bingo_list[j]:
            index = bingo_list[j].index(b)
            bingo_list[j][index] = -1


for i in range(3):
    cnt1 = 0
    cnt2 = 0
    for j in range(3):
        if bingo_list[i][j] == -1:
            cnt1 += 1
        if bingo_list[j][i] == -1:
            cnt2 += 1
    if cnt1 == 3 or cnt2 == 3:
        bingo_flag = True
        break

if bingo_list[0][0] == -1 and bingo_list[1][1] == -1 and bingo_list[2][2]:
    bingo_flag = True


if bingo_list[0][2] == -1 and bingo_list[1][1] == -1 and bingo_list[2][0]:
    bingo_flag = True

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

Solution (Python):
import numpy as np

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

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:
                a[r][c] = 0

a = np.array(a)
sum1 = a.sum(axis=0)
sum2 = a.sum(axis=1)
naname1 = a[0][0] + a[1][1] + a[2][2]
naname2 = a[0][2] + a[1][1] + a[2][0]

if 0 in sum1 or 0 in sum2 or naname1 == 0 or naname2 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
a=[]
for i in range(3):
  a1,a2,a3=map(int,input().split())
  a.append([a1,a2,a3])
  
check=[[0]*3 for i in range(3)]
n=int(input())
b=[]
for i in range(n):
  b.append(int(input()))
for i in b:
  for j in range(3):
    if i in a[j]:
      check[j][a[j].index(i)]=1

naname=[0]*3

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

for j in range(3):
  num=0
  for i in range(3):
    if check[i][j]==1:
      num+=1
      if num==3:
        print('Yes')
        sys.exit()
        
if check[0][0]==check[1][1]==check[2][2]==1:
  print('Yes')
  sys.exit()
if check[0][2]==check[1][1]==check[2][0]==1:
  print('Yes')
  sys.exit()
  
print('No')

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

flag = False
for i in range(n):
  b = int(input())
  for i in range(3):
    if a1[i] == b:
      a1[i] = 0
      flag = True
    if a2[i] == b:
      a2[i] = 0
      flag = True
    if a3[i] == b:
      a3[i] = 0
      flag = True

if flag == False:
  print('No')
else:
  if a1[0] == a2[0] == a3[0] == 0 or a1[1] == a2[1] == a3[1] == 0 or a1[2] == a2[2] == a3[2] == 0 or a1[0] == a1[1] == a1[2] == 0 or a2[0] == a2[1] == a2[2] == 0 or a3[0] == a3[1] == a3[2] == 0 or a1[0] == a2[1] == a3[2] == 0 or a3[0] == a2[1] == a1[2] == 0:
    print('Yes')
  else:
    print('No')

Solution (Python):
A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]
A3 = [int(x) for x in input().split()]
A = [A1, A2, A3]
B = [[False] * 3 for i in range(3)]
N = int(input())
b = [0]*N
for i in range(N):
  j = int(input())
  for m in range(3):
    for n in range(3):
        if A[m][n] == j:
          B[m][n] = True
def check():
    for i in range(3):
      if sum(B[i]) == 3:
        return "Yes"
    for j in range(3):
      if sum([B[k][j] for k in range(3)]) == 3:
        return "Yes"
    if B[0][0] + B[1][1] + B[2][2] == 3 or B[0][2] + B[1][1] + B[2][0] == 3:
      return "Yes"
    return "No"
 
print(check())

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

def check(A, b):
    
    for i in range(3):
        col, row = [], []
        for j in range(3):
            col.append(A[i][j])  
            row.append(A[j][i])  
        if set(col) <= b or set(row) <= b:
            return True

    
    if set([A[0][0], A[1][1], A[2][2]]) <= b or set([A[0][2], A[1][1], A[2][0]]) <= b:
        return True

if check(A, b):
    print('Yes')
else:
    print('No')

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

def check(A, b):
    
    for j in range(3):
        cand = []
        for i in range(3):
            cand.append(A[i][j])
        if set(cand) <= b:
            return True
        
    
    for i in range(3):
        cand = []
        for j in range(3):
            cand.append(A[i][j])
        if set(cand) <= b:
            return True

    
    if set([A[0][0], A[1][1], A[2][2]]) <= b or set([A[0][2], A[1][1], A[2][0]]) <= b:
        return True

if check(A, b):
    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()))
a1.extend(a2)
a1.extend(a3)
N = int(input())
b = [0]*N
for i in range(N):
  b[i] = int(input())
  if b[i] in a1:
    b1 = b[i]
    a1 = [0 if a1[j]==b1 else a1[j] for j in range(len(a1))]
n = sum(k==0 for k in a1)
if n >= 3:
  if n >= 7:
    print('Yes')
  elif a1[0]==a1[1]==a1[2] or a1[3]==a1[4]==a1[5] or a1[6]==a1[7]==a1[8] \
    or a1[0]==a1[3]==a1[6] or a1[1]==a1[4]==a1[7] or a1[2]==a1[5]==a1[8] \
    or a1[0]==a1[4]==a1[8] or a1[2]==a1[4]==a1[6]:
      print('Yes')
  else:
    print('No')
else:
  print('No')

Solution (Python):
d=[list(map(int,input().split()))for i in range(3)]
row=int(input())
num=[int(input()) for j in range(row)]
bingo=0
for a in range(3):
  if d[0][a] in num and d[1][a] in num and d[2][a] in num:
    bingo=bingo+1
  if d[a][0] in num and d[a][1] in num and d[a][2] in num:
    bingo=bingo+1
if d[1][1] in num and d[2][2] in num and d[0][0] in num:
  bingo=bingo+1
if d[1][1] in num and d[0][2] in num and d[2][0] in num:
  bingo=bingo+1
if bingo>0:
  print('Yes')
else:
  print('No')

Solution (Python):
a=[[0]*3 for i in range(3)]
b=[]
for i in range(3):
  x=input().split()
  a[i][0]=x[0]
  a[i][1]=x[1]
  a[i][2]=x[2]
n=int(input())
for i in range(n):
  b.append(input())
for i in range(n):
  for j in range(9):
    if b[i]==a[j//3][j%3]:
      a[j//3][j%3]='X'
jud=[0,0,0,0]
z=0
res=0
for i in range(3):
  for j in range(2):
    if a[i][j]==a[i][j+1]:
      jud[0]+=1
    if a[j][i]==a[j+1][i]:
      jud[1]+=1
  if max(jud)>1:
    res-=1
  else:
    jud[0]=0
    jud[1]=0
for j in range(2):
  if a[j][j]==a[j+1][j+1]:
    jud[2]+=1
  if a[j][2-j]==a[j+1][2-j-1]:
    jud[3]+=1
if max(jud)>1:
  res-=1
if res<0:
  print('Yes')
else:
  print('No')

Solution (Python):
def mark(number):
    """ビンゴシートにマークする

    Parameters
    ----------
    number : int
        出た数字
    """
    if number in yoko1:
        yoko1[number] = True

    if number in yoko2:
        yoko2[number] = True

    if number in yoko3:
        yoko3[number] = True

    if number in tate1:
        tate1[number] = True

    if number in tate2:
        tate2[number] = True

    if number in tate3:
        tate3[number] = True

    if number in naname1:
        naname1[number] = True

    if number in naname2:
        naname2[number] = True


def is_bingo():
    """ビンゴ達成したか否かを返す。
    """
    ans_list = []
    ans_list.append(False not in yoko1.values())
    ans_list.append(False not in yoko2.values())
    ans_list.append(False not in yoko3.values())
    ans_list.append(False not in tate1.values())
    ans_list.append(False not in tate2.values())
    ans_list.append(False not in tate3.values())
    ans_list.append(False not in naname1.values())
    ans_list.append(False not in naname2.values())

    return True in ans_list


row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
row3 = list(map(int, input().split()))

yoko1 = {row1[0]: False, row1[1]: False, row1[2]: False}
yoko2 = {row2[0]: False, row2[1]: False, row2[2]: False}
yoko3 = {row3[0]: False, row3[1]: False, row3[2]: False}

tate1 = {row1[0]: False, row2[0]: False, row3[0]: False}
tate2 = {row1[1]: False, row2[1]: False, row3[1]: False}
tate3 = {row1[2]: False, row2[2]: False, row3[2]: False}

naname1 = {row1[0]: False, row2[1]: False, row3[2]: False}
naname2 = {row1[2]: False, row2[1]: False, row3[0]: False}

N = int(input())

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

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

Solution (Python):
import math

bingo_card = []
for i in range(3):
    bingo_card.append(list(map(int, input().split())))
    
num = int(input())

numbers = []
for i in range(num):
    numbers.append(int(input()))

position = []
for i in numbers:
    for j, column in enumerate(bingo_card):
        for k, num in enumerate(column):
            if i == num:
                position.append([j, k])

def main():
    for i in range(3):
        column_cnt = len(list(filter(lambda x : x[0] == i , position)))
        if (column_cnt == 3):
            return True
    
    for i in range(3):
        column_cnt = len(list(filter(lambda x : x[1] == i , position)))
        if (column_cnt == 3):
            return True
    
    x_1 = 0    
    for i in position:
        if (i == [0,0] or i == [1,1] or i == [2,2]):
            x_1 += 1
    
    if(x_1 == 3):
        return True
        
    x_2 = 0    
    for i in position:
        if (i == [0,2] or i == [1,1] or i == [2,0]):
            x_2 += 1
    
    if(x_2 == 3):
        return True
    
    return False

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

Solution (Python):
from collections import defaultdict


def main():

    def is_in(a, b):
        return (a, b) in nums_points

    flag = 0
    mat = [
        list(map(int, input().split())),
        list(map(int, input().split())),
        list(map(int, input().split()))
    ]

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

    combs = defaultdict(int)
    for i in range(3):
        for j in range(3):
            combs[mat[i][j]] = (i, j)

    nums_points = []
    for n in nums:
        nums_points.append(combs[n])

    if is_in(0, 0) and is_in(0, 1) and is_in(0, 2):
        flag += 1
    if is_in(1, 0) and is_in(1, 1) and is_in(1, 2):
        flag += 1
    if is_in(2, 0) and is_in(2, 1) and is_in(2, 2):
        flag += 1
    if is_in(0, 0) and is_in(1, 0) and is_in(2, 0):
        flag += 1
    if is_in(0, 1) and is_in(1, 1) and is_in(2, 1):
        flag += 1
    if is_in(0, 2) and is_in(1, 2) and is_in(2, 2):
        flag += 1
    if is_in(0, 0) and is_in(1, 1) and is_in(2, 2):
        flag += 1
    if is_in(0, 2) and is_in(1, 1) and is_in(2, 0):
        flag += 1

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


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

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

N = int(input());


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


A = np.hstack([A1,A2,A3]);

for i in range(N):
  for j in range(len(A)):
    if B[i] == A[j]:
      A[j] = 0;
      break;
    else:
      pass;


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

Solution (Python):
from collections import defaultdict


def main():

    def is_in(a, b):
        return (a, b) in nums_points

    flag = 0
    row1 = list(map(int, input().split()))
    row2 = list(map(int, input().split()))
    row3 = list(map(int, input().split()))

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

    mat = [row1, row2, row3]
    combs = defaultdict(int)
    for i in range(3):
        for j in range(3):
            combs[mat[i][j]] = (i, j)

    nums_points = []
    for n in nums:
        nums_points.append(combs[n])

    if is_in(0, 0) and is_in(0, 1) and is_in(0, 2):
        flag += 1
    if is_in(1, 0) and is_in(1, 1) and is_in(1, 2):
        flag += 1
    if is_in(2, 0) and is_in(2, 1) and is_in(2, 2):
        flag += 1
    if is_in(0, 0) and is_in(1, 0) and is_in(2, 0):
        flag += 1
    if is_in(0, 1) and is_in(1, 1) and is_in(2, 1):
        flag += 1
    if is_in(0, 2) and is_in(1, 2) and is_in(2, 2):
        flag += 1
    if is_in(0, 0) and is_in(1, 1) and is_in(2, 2):
        flag += 1
    if is_in(0, 2) and is_in(1, 1) and is_in(2, 0):
        flag += 1

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


if __name__ == "__main__":
    main()