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):

A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
n = int(input())
b = [int(input()) for _ in range(n)]
B1 = [0,0,0] 
B2 = [0,0,0]
B3 = [0,0,0]

for i in b:
    if i in A1:
        x = A1.index(i)
        B1[x] = 1
    if i in A2:
        x = A2.index(i)
        B2[x] = 1
    if i in A3:
        x = A3.index(i)
        B3[x] = 1

if B1[0] == B1[1] == B1[2] == 1 or B2[0] == B2[1] == B2[2] == 1 or B3[0] == B3[1] == B3[2] == 1:
    print("Yes")
    exit()
elif B1[0] == B2[0] == B3[0] == 1 or B1[1] == B2[1] == B3[1] == 1 or B1[2] == B2[2] == B3[2] == 1 or B1[0] == B2[1] == B3[2] == 1 or B1[2] == B2[1] == B3[0] == 1:
    print("Yes")
    exit()
else:
    print("No")

Solution (Python):
import numpy as np


def solve():
    sheet = np.zeros(9)
    bingo_inds = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 4, 8], [2, 4, 6], [0, 3, 6], [1, 4, 7], [2, 5, 8]]
    for bi in b:
        if bi in hm:
            sheet[hm[bi]] = 1
    for bi in bingo_inds:
        if sum(np.take(sheet, bi)) == 3:
            print("Yes")
            exit()
    print("No")


r1 = [int(s) for s in input().split(" ")]
r1.extend([int(s) for s in input().split(" ")])
r1.extend([int(s) for s in input().split(" ")])
hm = {v: i for i, v in enumerate(r1)}
n = int(input())
b = [int(input()) for i in range(n)]
solve()

Solution (Python):
A = [0] * 3
bingo = [0] * 3
for i in range(3):
    A[i] = list(map(int, input().split()))
    bingo[i] = [0, 0, 0]
N = int(input())
b = [0] * N
for k in range(N):
    b[k] = int(input())
for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] == b[k]:
                bingo[i][j] = 1

vert = max([sum(bingo[i]) for i in range(3)])
hori = max([sum([bingo[i][j] for i in range(3)]) for j in range(3)])
cros = max(bingo[0][0]+bingo[1][1]+bingo[2][2], bingo[0][2]+bingo[1][1]+bingo[2][0])

if max(vert, hori, cros) == 3:
    print('Yes')
else:
    print('No')

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

num0 = 0
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
                num0 += 1
                if num0 >= 3:
                    if max(A[0]) == 0 or max(A[1]) == 0 or max(A[2]) == 0:
                        print("Yes")
                        exit()
                    elif A[0][0] == A[1][0] == A[2][0] == 0:
                        print("Yes")
                        exit()
                    elif A[0][1] == A[1][1] == A[2][1] == 0:
                        print("Yes")
                        exit()
                    elif A[0][2] == A[1][2] == A[2][2] == 0:
                        print("Yes")
                        exit()
                    elif A[0][0] == A[1][1] == A[2][2] == 0:
                        print("Yes")
                        exit()
                    elif A[0][2] == A[1][1] == A[2][0] == 0:
                        print("Yes")
                        exit()

print("No")

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

num0 = 0
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
                num0 += 1
                if num0 >= 3:
                    if max(A[0]) == 0 or max(A[1]) == 0 or max(A[2]) == 0:
                        print("Yes")
                        exit()
                    elif A[0][0] == A[1][0] == A[2][0] == 0:
                        print("Yes")
                        exit()
                    elif A[0][1] == A[1][1] == A[2][1] == 0:
                        print("Yes")
                        exit()
                    elif A[0][2] == A[1][2] == A[2][2] == 0:
                        print("Yes")
                        exit()
                    elif A[0][0] == A[1][1] == A[2][2] == 0:
                        print("Yes")
                        exit()
                    elif A[0][2] == A[1][1] == A[2][0] == 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)]

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

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


f = False
for i in range(3):
    tmpf = True
    for j in range(3):
        if bingo[i][j] == 0:
            tmpf = False
    if tmpf:
        f = True

for i in range(3):
    tmpf = True
    for j in range(3):
        if bingo[j][i] == 0:
            tmpf = False
    if tmpf:
        f = True

if bingo[0][0] == 1 and bingo[1][1] == 1 and bingo[2][2] == 1:
    f = True
if bingo[0][2] == 1 and bingo[1][1] == 1 and bingo[2][0] == 1:
    f = True

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

Solution (Python):
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    A1 = LI()
    A2 = LI()
    A3 = LI()
    N = II()
    b = [int(input()) for i in range(N)]
    ans = 0
    

    if b.count(A2[1])!=0:
        if (b.count(A1[0])!=0 and b.count(A3[2])!=0) or (b.count(A3[0])!=0 and b.count(A1[2])!=0) or (b.count(A1[1])!=0 and b.count(A3[1])!=0) or(b.count(A2[0])!=0 and b.count(A2[2])!=0) :
            ans += 1
    if b.count(A1[0])!=0:
        if (b.count(A2[0])!=0 and b.count(A3[0])!=0) or (b.count(A1[1])!=0 and b.count(A1[2])!=0) :
            ans += 1
    if b.count(A3[2])!=0:
        if (b.count(A1[2])!=0 and b.count(A2[2])!=0) or (b.count(A3[0])!=0 and b.count(A3[1])!=0) :
            ans += 1
    if ans != 0:
        print("Yes")
    else:
        print("No")




if __name__ == "__main__":
	main()

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

c = [[0,0,0],[0,0,0],[0,0,0]]
P = [{0,3,6},{1,4,7},{2,5,8},{0,1,2},{3,4,5},{6,7,8},{0,4,8},{2,4,6}]

r = []
for i,a in enumerate(A):
    if a in B:
        r.append(i)
r = set(r)

for p in P:
    if p.issubset(r):
        print('Yes')
        break
else:
    print('No')

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

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

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

win = False
for i in range(3):
    row = bingo[i]
    if all(row):
        win = True

for j in range(3):
    col = [bingo[i][j] for i in range(3)]
    if all(col):
        win = True

d1 = [bingo[0][0], bingo[1][1], bingo[2][2]]
d2 = [bingo[0][2], bingo[1][1], bingo[2][0]]

if all(d1) or all(d2):
    win = True

if win:
    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()))
alist = [a1,a2,a3]
N = int(input())
blist = [int(input()) for i in range(N)]
for i in range(N):
    for j in range(3):
        for k in range(3):
            if blist[i] == alist[j][k]:
                alist[j][k] = 0
if alist[0] == [0,0,0] or alist[1] == [0,0,0] or alist[2] == [0,0,0] or [alist[0][0],alist[1][0],alist[2][0]] == [0,0,0] or [alist[0][1],alist[1][1],alist[2][1]] == [0,0,0] or [alist[0][2],alist[1][2],alist[2][2]] == [0,0,0] or [alist[0][0],alist[1][1],alist[2][2]] == [0,0,0] or [alist[2][0],alist[1][1],alist[0][2]] == [0,0,0]:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np
a1 = np.array(input().split(),dtype=int)
a2 = np.array(input().split(),dtype=int)
a3 = np.array(input().split(),dtype=int)
n = int(input())
ban = []
for i in range(3):
    ban.append(a1[i])
for i in range(3):
    ban.append(a2[i])
for i in range(3):
    ban.append(a3[i])
b = [0 for i in range(9)]
for i in range(n):
    x = int(input())
    if x in ban:
        b[ban.index(x)] = 1

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

Solution (Python):
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
n=int(input())
d=[0,0,0]
e=[0,0,0]
f=[0,0,0]
for i in range(n):
    ab=int(input())
    for i in range(3):
        if a[i] == ab:
            d[i] = 1
        if b[i] == ab:
            e[i] = 1
        if c[i] == ab:
            f[i] = 1
if sum(d)==3 or sum(e)==3 or sum(f)==3:
    print("Yes")
    exit()

for i in range(3):
    if d[i]==e[i]==f[i]==1:
        print("Yes")
        exit()
if d[0]==e[1]==f[2]==1 or d[2]==e[1]==f[0]==1:
    print("Yes")
    exit()
print("No")

Solution (Python):
C=list(map(int,input().split()))
D=list(map(int,input().split()))
E=list(map(int,input().split()))
F=[0,0,0]
G=[0,0,0]
H=[0,0,0]
N=int(input())
for j in range(N):
  b=int(input())
  for i in range(3):
    if b==C[i]:
      F[i]=1
    if b==D[i]:
      G[i]=1
    if b==E[i]:
      H[i]=1
      
for k in range(3):
  if F[k]==G[k]==H[k]==1:
    print('Yes')
    exit()

if sum(F)==3 or sum(G)==3 or sum(H)==3:
  print('Yes')
  exit()

if F[0]==G[1]==H[2]==1 or F[2]==G[1]==H[0]==1:
  print('Yes')
  exit()

print('No')

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

check=0
for i in range(3):
    if (a[3*i]==a[3*i+1] and a[3*i+1]==a[3*i+2]) or (a[i]==a[i+3] and a[i+3]==a[i+6]):
        check+=1
if (a[0]==a[4] and a[4]==a[8]) or (a[2]==a[4] and a[4]==a[6]):
    check+=1
if check>0:
    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())
listb = [int(input()) for i in range(N)]

for item in listb:
    for i in range(3):
        if A1[i] == item:
            A1[i] = 0
    for j in range(3):
        if A2[j] == item:
            A2[j] = 0
    for k in range(3):
        if A3[k] == item:
            A3[k] = 0
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print('Yes')
    exit()
for i in range(3):
    if A1[i] == A2[i] and A2[i] == A3[i]:
        print('Yes')
        exit()
if A1[0] == A2[1] == A3[2] or A1[2] == A2[1] == A3[0]:
    print('Yes')
    exit()
print('No')

Solution (Python):
import numpy as np

A = [0] * 3
A[0] = list(map(int,input().split()))
A[1] = list(map(int,input().split()))
A[2] = list(map(int,input().split()))
N = int(input())
bn = []
for n in range(N):
  bn.append(int(input()))
for i in range(3):
  for j in range(3):
    A[i][j] = A[i][j] in bn
A = np.array(A)
if sum(np.prod(A,1)) != 0:
  print('Yes')
elif sum(np.prod(A,0)) != 0:
  print('Yes')
elif A[0][0] * A[1][1] * A[2][2] != 0:
  print('Yes')
elif A[2][0] * A[1][1] * A[0][2] != 0:
  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)]

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 or a[0][2] == a[1][1] == a[2][0] == 0:
    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)]

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

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

Solution (Python):
A = list(map(int,input().split()))
A456 = list(map(int,input().split()))
A789 = list(map(int,input().split()))
A.extend(A456)
A.extend(A789)
N = int(input())
B = []
for i in range(N):
    b = int(input())
    B.append(b)
for i in range(9):
    for u in range(N):
        if A[i] == B[u]:
            A[i] = 0
if A[0] + A[1] + A[2] == 0 or  A[3] + A[4] + A[5] == 0 or A[6] + A[7] + A[8] == 0 :
    print("Yes")
elif A[0] + A[3] + A[6] == 0 or A[1] + A[4] + A[7] == 0 or A[2] + A[5] + A[8] == 0:
    print("Yes")
elif A[0] + A[4] + A[8] == 0 or A[2] + A[4] + A[6] == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
A = []
[A.extend(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
for b in B:
    try:
        i = A.index(b)
        A[i] = 0
    except:
        pass
lines = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 4, 8],
    [2, 4, 6],
]
ans = "No"
for line in lines:
    a, b, c = line
    if A[a] == 0 and A[a] == A[b] and A[a] == A[c]:
        ans = "Yes"
print(ans)

Solution (Python):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
n = int(input())
b = [int(input()) for i in range(n)]
ans = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]
tmp = []
for i in range(3):
    for j in range(len(b)):
        if b[j] == A1[i]:
            A1[i] = 0
        elif b[j] == A2[i]:
            A2[i] = 0
        
        elif b[j] == A3[i]:
            A3[i] = 0


if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print("Yes")

elif A1[0]+A2[0]+A3[0] == 0 or A1[1]+A2[1]+A3[1] == 0 or A1[2]+A2[2]+A3[2] == 0:
    print("Yes")

elif A1[0]+A2[1]+A3[2] == 0 or A1[2]+A2[1]+A3[0] == 0:
    print("Yes")

else:
    print("No")

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

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

for y in range(3):
    for z in range(3):
        for x in B:
            if x == A[y][z]:
                A[y][z] = -1

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

Solution (Python):


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

for i in range(N):
    b = int(input())
    for 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):
bingo = []
card = [[0,0,0],[0,0,0],[0,0,0]]
ans = 0
for i in range(3):
    A = list(map(int,input().split()))
    bingo.append(A)
N = int(input())
for i in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b:
                card[i][j] += 1
if card[0][0]+card[0][1]+card[0][2] >= 3:
    ans += 1
if card[0][0]+card[1][0]+card[2][0] >= 3:
    ans += 1
if card[1][0]+card[1][1]+card[1][2] >= 3:
    ans += 1
if card[2][0]+card[2][1]+card[2][2] >= 3:
    ans += 1
if card[0][1]+card[1][1]+card[2][1] >= 3:
    ans += 1
if card[0][2]+card[1][2]+card[2][2] >= 3:
    ans += 1
if card[0][0]+card[1][1]+card[2][2] >= 3:
    ans += 1
if card[0][2]+card[1][1]+card[2][0] >= 3:
    ans += 1
if ans > 0:
    print("Yes")
else:
    print("No")

Solution (Python):

A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]

for i in range(3):
  for j in range(N):
    if A1[i] == b[j]:
      A1[i] = 0
for i in range(3):
  for j in range(N):
    if A2[i] == b[j]:
      A2[i] = 0
for i in range(3):
  for j in range(N):
    if A3[i] == b[j]:
      A3[i] = 0
ans = 'No'

if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
  ans = 'Yes'

elif (A1[0] == 0 and A2[0] == 0 and A3[0] == 0) or (A1[1] == 0 and A2[1] == 0 and A3[1] == 0) or (A1[2] == 0 and A2[2] == 0 and A3[2] == 0):
  ans = 'Yes'

elif (A1[0] == 0 and A2[1] == 0 and A3[2] == 0) or (A1[2] == 0 and A2[1] == 0 and A3[0] == 0):
  ans = 'Yes'

print(ans)

Solution (Python):
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
n = int(input())
l = [0]*n
for i in range(n):
    l[i] = int(input())
    for j in range(3):
        if l[i] == a[j]:
            a[j] = 0
        elif l[i] == b[j]:
            b[j] = 0
        elif l[i] == c[j]:
            c[j] = 0
ans = 'No'
if a[0]+a[1]+a[2] == 0 or b[0]+b[1]+b[2] == 0 or c[0]+c[1]+c[2] == 0:
    ans = 'Yes'
if a[0]+b[0]+c[0] == 0 or a[1]+b[1]+c[1] == 0 or a[2]+b[2]+c[2] == 0:
    ans = 'Yes'
if a[0]+b[1]+c[2] == 0 or a[2]+b[1]+c[0] == 0:
    ans = 'Yes'
print(ans)

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

fl = False 

B = [[False for i in range (3)] for i in range(3)]

N = int(input())
for b in range (N) :
    tmp = input()
    for i in range (3) :
        for j in range (3) :
            if int(tmp) == int(A[i][j]) :
                B[i][j] = True

if B[0][0] and B[1][1] and B[2][2] :
    fl = True
elif B[0][2] and B[1][1] and B[2][0] :
    fl = True
elif B[0][0] and B[0][1] and B[0][2] :
    fl = True
elif B[1][0] and B[1][1] and B[1][2] :
    fl = True
elif B[2][0] and B[2][1] and B[2][2] :
    fl = True
elif B[0][0] and B[1][0] and B[2][0] :
    fl = True
elif B[0][1] and B[1][1] and B[2][1] :
    fl = True
elif B[0][2] and B[1][2] and B[2][2] :
    fl = True

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

Solution (Python):
a = []
use = [[False for i in range (3)] for j in range (3)]
ha = {}
cntRow = [0 for i in range (3)]
cntCol = [0 for i in range (3)]

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

n = int (input ())

for i in range (n) :
    b = int (input ())
    if (not b in ha.keys ()) :
        continue
    if (not use[ha[b][0]][ha[b][1]]) :
        use[ha[b][0]][ha[b][1]] = True
        cntRow[ha[b][0]] += 1
        cntCol[ha[b][1]] += 1

flg = False
for i in range (3) :
    if (cntCol[i] == 3 or cntRow[i] == 3) :
        flg = True

if (not flg) :
    if (use[1][1] and (use[0][0] and use[2][2] or use[0][2] and use[2][0])) :
        flg = True

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

Solution (Python):
def resolve():
    a11,a12,a13=map(int, input().split())
    a21,a22,a23=map(int, input().split())
    a31,a32,a33=map(int, input().split())
    n=int(input())
    lyo1=[a11,a12,a13]
    lyo2=[a21,a22,a23]
    lyo3=[a31,a32,a33]
    lta1=[a11,a21,a31]
    lta2=[a12,a22,a32]
    lta3=[a13,a23,a33]
    lna1=[a11,a22,a33]
    lna2=[a13,a22,a31]
    yo1=0
    yo2=0
    yo3=0
    ta1=0
    ta2=0
    ta3=0
    na1=0
    na2=0
    b=[int(input()) for i in range(n)]
    for x in range(n):
        if b[x] in lyo1:
            yo1+=1
        if b[x] in lyo2:
            yo2+=1
        if b[x] in lyo3:
            yo3+=1
        if b [x] in lta1:
            ta1+=1
        if b[x] in lta2:
            ta2+=1
        if b[x] in lta3:
            ta3+=1
        if b[x] in lna1:
            na1+=1
        if b[x] in lna2:
            na2+=1

    if yo1==3 or yo2==3 or yo3==3 or ta1==3 or ta2==3 or ta3==3 or na1==3 or na2==3:
        print('Yes')
    else:
        print('No')
resolve()

Solution (Python):
def solve():
    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):
        if (A[i][0] in b and A[i][1] in b and A[i][2] in b) or (A[0][i] in b and A[1][i] in b and A[2][i] in b):
            print('Yes')
            return
    if (A[0][0] in b and A[1][1] in b and A[2][2] in b) or (A[2][0] in b and A[1][1] in b and A[0][2] in b):
        print('Yes')
        return
    print('No')

solve()

Solution (Python):
ls1 = list(map(int, input().split()))
ls2 = list(map(int, input().split()))
ls3 = list(map(int, input().split()))
n = int(input())

for i in range(n):
    b = int(input())
    if b in ls1:
        x = ls1.index(b)
        ls1[x] = 0
    if b in ls2:
        x = ls2.index(b)
        ls2[x] = 0
    if b in ls3:
        x = ls3.index(b)
        ls3[x] = 0

if ls1[0] + ls2[0] + ls3[0] == 0 or \
    ls1[1] + ls2[1] + ls3[1] == 0 or \
    ls1[2] + ls2[2] + ls3[2] == 0 or \
    ls1[0] + ls1[1] + ls1[2] == 0 or \
    ls2[0] + ls2[1] + ls2[2] == 0 or \
    ls3[0] + ls3[1] + ls3[2] == 0 or \
    ls1[0] + ls2[1] + ls3[2] == 0 or \
    ls3[0] + ls2[1] + ls1[2] == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
a = [list(map(int, input().split())) for row in range(3)]
n = int(input())
b = [int(input()) for hoge in range(n)]
a1 = a[0] + a[1] + a[2]
c = []
for poge in a1:
  if poge in b:
    c.append(0)
  else:
    c.append(1)
if min((c[0]+c[1]+c[2]),(c[3]+c[4]+c[5]),(c[6]+c[7]+c[8]),(c[0]+c[3]+c[6]),
      (c[1]+c[4]+c[7]),(c[2]+c[5]+c[8]),(c[0]+c[4]+c[8]),(c[2]+c[4]+c[6])) == 0:
  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)]

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 or a[0][2]+a[1][1]+a[2][0]==0:
    ans = "Yes"

print(ans)

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

def readlines(n):
    for i in range(n):
        for j, x in enumerate(input().split()):
            yield int(x), (i, j)

def bingo(card):
    if any(all(row) for row in card):
        return True
    
    if any(all(row[i] for row in card) for i in range(3)):
        return True
    
    if all(card[i][i] for i in range(3)):
        return True

    if all(card[2-i][i] for i in range(3)):
        return True

def main():
    A = dict(readlines(3))
    card = [[False]*3 for _ in range(3)]
    n = int(input())
    for _ in range(n):
        b = int(input())
        if b in A:
            y, x = A[b]
            card[y][x] = True
        if bingo(card):
            print("Yes")
            return
    
    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())
sheet = [
    [0,0,0],
    [0,0,0],
    [0,0,0],
]
for x in range(n):
    b = int(input())
    if b in a1:
        sheet[0][a1.index(b)] = 1
    elif b in a2:
        sheet[1][a2.index(b)] = 1
    elif b in a3:
        sheet[2][a3.index(b)] = 1
if (sum(sheet[0]) == 3 
    or sum(sheet[1]) == 3 
    or sum(sheet[2]) == 3
    or sheet[0][0] == sheet[1][0] == sheet[2][0] == 1
    or sheet[0][1] == sheet[1][1] == sheet[2][1] == 1
    or sheet[0][2] == sheet[1][2] == sheet[2][2] == 1
    or sheet[0][0] == sheet[1][1] == sheet[2][2] == 1
    or sheet[0][2] == sheet[1][1] == sheet[2][0] == 1):
    print('Yes')
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()))


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


flag = False
for c in C:
  
  
  
  if len(list(set(c) & set(b))) == 3:
    flag = True
    
    break


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

Solution (Python):
map_dict = dict()
for i in range(3):
    a1, a2, a3 = input().split()
    map_dict[a1] = 1 + i * 3
    map_dict[a2] = 2 + i * 3
    map_dict[a3] = 3 + i * 3

win_pattern = [
    (1, 2, 3),
    (4, 5, 6),
    (7, 8, 9),
    (1, 4, 7),
    (2, 5, 8),
    (3, 6, 9),
    (1, 5, 9),
    (3, 5, 7),
]
n = int(input())
scored = []
for i in range(n):
    b = input()
    try:
        scored.append(map_dict[b])
    except:
        pass
scored = set(scored)

flag = False
for pattern in win_pattern:
    if set(pattern).issubset(scored):
        print('Yes')
        flag = True
        break
if not flag:
    print('No')

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

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

for i in B:
  if i in A:
    A[A.index(i)] = 0

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

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

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

for i in B:
  if i in A:
    A[A.index(i)] = 0

for i in range(3):
  if A[i] + A[i+3] + A[i+6] == 0:
    Flag = True
  if A[3*i] + A[3*i+1] + A[3*i+2] == 0:
    Flag = True

if A[0] + A[4] + A[8] == 0 or A[2] + A[4] + A[6] == 0:
  Flag = True

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

Solution (Python):

A = [input().split() for _ in range(3)]
N = int(input())
b = [input() for _ in range(N)]

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

isBingo = 'No'

for i in range(3):
    if A[i][0] + A[i][1] + A[i][2] == '000':
        isBingo = 'Yes'
        break

for j in range(3):
    if A[0][j] + A[1][j] + A[2][j] == '000':
        isBingo = 'Yes'
        break

if A[0][0] + A[1][1] + A[2][2] == '000' or A[2][0] + A[1][1] + A[0][2] == '000':
    isBingo = 'Yes'

print(isBingo)

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

for i in range(3):
    for j in range(3):
        if bingo[i][j] in ls:
            bingo[i][j] = 1
        else:
            bingo[i][j] = 0

if sum(bingo[0]) == 3 or sum(bingo[1]) == 3 or sum(bingo[2]) == 3:
    print('Yes')
    exit()

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

if bingo[0][0] + bingo[1][1] + bingo[2][2] == 3 or bingo[0][2] + bingo[1][1] + bingo[2][0] == 3:
    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 i in range(3):
    for j in range(3):
      if b == A[i][j]:
        A[i][j] = 101
result = "No"
for i in range(3):
  if A[i].count(101) == 3:
    result = "Yes"
  elif A[0][i] == 101 and A[1][i] == 101 and A[2][i] == 101:
    result = "Yes"
if (A[0][0] == 101 and A[1][1] == 101 and A[2][2] == 101) or (A[0][2] == 101 and A[1][1] == 101 and A[2][0] == 101):
    result = "Yes"
print(result)

Solution (Python):
import itertools
def checkbingo(A_match):
  for i in range(3):
      if 0 not in A_match[i * 3: (i + 1) * 3]:
          return 'Yes'
  for i in range(3):
      if 0 not in A_match[i: i + 7: 3]:
          return 'Yes'
  if 0 not in A_match[0: 8: 4]:
      return 'Yes'
  if 0 not in A_match[2: 7: 2]:
      return 'Yes'
  return 'No'  

def main():
  n=3
  A = [list(map(int, input().split())) for _ in range(n)]
  A=list(itertools.chain.from_iterable(A))
  N=int(input())
  b = [int(input()) for _ in range(N)]
  A_match = [0] * 9
  for i in range(n*n):
    tgtA=A[i]
    if(tgtA in b):
      A_match[i]=1
  print(checkbingo(A_match))
        
      
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)]
mark = [[False, False, False] for _ in range(3)]

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

ans = 'No'

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


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


if (mark[0][0] and mark[1][1] and mark[2][2]) or (mark[0][2] and mark[1][1] and mark[2][0]):
    ans = 'Yes'

print(ans)

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

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

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

ans = False
if A[0][0] == A[1][1] == A[2][2] == 0:
    ans = True

if A[0][2] == A[1][1] == A[2][0] == 0:
    ans = True


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


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

print("Yes" if ans else "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 b:
      if a[j][i] == k:
            a[j][i] = 'o'
a1 = list(set(a[0]))
a2 = list(set(a[1]))
a3 = list(set(a[2]))
a4 = list(set((a[0][0],a[1][1],a[2][2])))
a5 = list(set((a[0][2],a[1][1],a[2][0])))
a6 = list(set((a[0][0],a[1][0],a[2][0])))
a7 = list(set((a[0][1],a[1][1],a[2][1])))
a8 = list(set((a[0][2],a[1][2],a[2][2])))
p = ['o']
A = [a1,a2,a3,a4,a5,a6,a7,a8]
for i in A:
    ans = 'No'
    if i == p:
        ans = 'Yes'
        break
print(ans)