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



def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    
    bing = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    for num in b:
        for i in bing:
            try:
                while True:
                    t = i.index(num)
                    i[t] = -1
            except:
                continue
    

    naname = [((0, 0), (1, 1), (2, 2)), (2, 0), (1, 1), (0, 2)]
    if sum(bing[0]) == -3 or sum(bing[1]) == -3 or sum(bing[2]) == -3 or bing[0][0]+bing[1][0]+bing[2][0] == -3 or bing[0][1]+bing[1][1]+bing[2][1] == -3 or bing[0][2]+bing[1][2]+bing[2][2] == -3 or bing[0][0]+bing[1][1]+bing[2][2] == -3 or bing[0][2]+bing[1][1]+bing[2][0] == -3:
        print('Yes')
        exit(0)

    print('No')


if __name__ == '__main__':
    main()

Solution (Python):
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
list3 = list(map(int, input().split()))
bingo = [list1, list2, list3]
n = int(input())
b_list = []

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

for i in range(3):
    for j in range(3):
        if bingo[i][j] in b_list:
            bingo[i][j] = 'X'

pattern_list =[]
pattern_list.append(bingo[0])
pattern_list.append(bingo[1])
pattern_list.append(bingo[2])
pattern_list.append([bingo[0][0], bingo[1][0], bingo[2][0]])
pattern_list.append([bingo[0][1], bingo[1][1], bingo[2][1]])
pattern_list.append([bingo[0][2], bingo[1][2], bingo[2][2]])
pattern_list.append([bingo[0][0], bingo[1][1], bingo[2][2]])
pattern_list.append([bingo[0][2], bingo[1][1], bingo[2][0]])

if ['X', 'X', 'X'] in pattern_list:
    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()))

ans = False
for i in range(3):
	c = 0
	for j in range(3):
		if a[i][j] in b:
			a[i][j] = 0
			c += 1
	if c == 3:
		ans = True
		break

if ans :
	print('Yes')
elif a[0][0] + a[1][0] + a[2][0] == 0:
	print('Yes')
elif a[0][1] + a[1][1] + a[2][1] == 0:
	print('Yes')
elif a[0][2] + a[1][2] + a[2][2] == 0:
	print('Yes')
elif a[0][0] + a[1][1] + a[2][2] == 0:
	print('Yes')
elif a[0][2] + a[1][1] + a[2][0] == 0:
	print('Yes')
else:
	print('No')

Solution (Python):
bng = []
for i1 in range(3):
    row = list(map(int,input().rstrip().split()))
    bng.append(row)



N = int(input())

for l1 in range(N):
    tmp = int(input())
    for l2 in range(3):
        for l3 in range(3):
            if tmp == bng[l2][l3]:
                bng[l2][l3] = 0

if bng[0][0] + bng[0][1] + bng[0][2] == 0:
    print('Yes')
elif bng[1][0] + bng[1][1] + bng[1][2] == 0:
    print('Yes')
elif bng[2][0] + bng[2][1] + bng[2][2] == 0:
    print('Yes')
elif bng[0][0] + bng[1][0] + bng[2][0] == 0:
    print('Yes')
elif bng[0][1] + bng[1][1] + bng[2][1] == 0:
    print('Yes')
elif bng[0][2] + bng[1][2] + bng[2][2] == 0:
    print('Yes')
elif bng[0][2] + bng[1][1] + bng[2][0] == 0:
    print('Yes')
elif bng[0][0] + bng[1][1] + bng[2][2] == 0:
    print('Yes')
else:
    print('No')

Solution (Python):

"""
Created on Sun Mar  1 20:52:24 2020

@author: H_Hoshigi
"""

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

N = int(input())

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

bingo_line_list =[
    [0,1,2],
    [3,4,5],
    [6,7,8],
    [0,3,6],
    [1,4,7],
    [2,5,8],
    [0,4,8],
    [2,4,6]
    ]
at_least_one_bingo = False
for i in bingo_line_list:
    get_bingo = True
    for j in i:
        if A_list[j] not in b_list:
            get_bingo = False
            break
    if get_bingo:
        at_least_one_bingo = True
        break
if at_least_one_bingo:
    print("Yes")
else:
    print("No")

Solution (Python):



def isBingo(bingocard, calledlist):
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    

    
    if bingocard[0][0] in calledlist and bingocard[0][1] in calledlist and bingocard[0][2] in calledlist:
        return 'Yes'
    if bingocard[1][0] in calledlist and bingocard[1][1] in calledlist and bingocard[1][2] in calledlist:
        return 'Yes'
    if bingocard[2][0] in calledlist and bingocard[2][1] in calledlist and bingocard[2][2] in calledlist:
        return 'Yes'
    
    if bingocard[0][0] in calledlist and bingocard[1][0] in calledlist and bingocard[2][0] in calledlist:
        return 'Yes'
    if bingocard[0][1] in calledlist and bingocard[1][1] in calledlist and bingocard[2][1] in calledlist:
        return 'Yes'
    if bingocard[0][2] in calledlist and bingocard[1][2] in calledlist and bingocard[2][2] in calledlist:
        return 'Yes'

    
    if bingocard[0][0] in calledlist and bingocard[1][1] in calledlist and bingocard[2][2] in calledlist:
        return 'Yes'
    if bingocard[0][2] in calledlist and bingocard[1][1] in calledlist and bingocard[2][0] in calledlist:
        return 'Yes'
    else:
        return 'No'


l1 = [int(each) for each in input().split(' ')]
l2 = [int(each) for each in input().split(' ')]
l3 = [int(each) for each in input().split(' ')]
bingocard = [l1, l2, l3]

calledlist = []
for called in range(int(input())):
    calledlist.append(int(input()))

print(isBingo(bingocard, calledlist))

Solution (Python):
arr = []
ptr = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 4, 8],
    [2, 4, 6]]
for i in range(3):
    row = list(map(int, input().split()))
    arr.extend(row)
bingo = [False] * 9
N = int(input())
for i in range(N):
    n = int(input())
    if n in arr:
        idx = arr.index(n)
        bingo[idx] = True
for p in ptr:
    if all([bingo[idx] for idx in p]):
        print("Yes")
        exit(0)
print("No")

Solution (Python):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
A = []
for a in a1:
  A.append([a, False])
for a in a2:
  A.append([a, False])
for a in a3:
  A.append([a, False])

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

for i, a in enumerate(A):
  if (a[0] in B):
    A[i][1] = True

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

print(result)

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

flag = False
if A11 in B and A12 in B and A13 in B:
    flag = True
elif A21 in B and A22 in B and A23 in B:
    flag = True
elif A31 in B and A32 in B and A33 in B:
    flag = True
elif A11 in B and A21 in B and A31 in B:
    flag = True
elif A12 in B and A22 in B and A32 in B:
    flag = True
elif A13 in B and A23 in B and A33 in B:
    flag = True
elif A11 in B and A22 in B and A33 in B:
    flag = True
elif A13 in B and A22 in B and A31 in B:
    flag = True

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

Solution (Python):
one = list(map(int, input().split()))
two = list(map(int, input().split()))
thr = list(map(int, input().split()))

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

ans = False


if one[0] in b and two[1] in b and thr[2] in b:
    ans = True
if one[2] in b and two[1] in b and thr[0] in b:
    ans = True

if one[0] in b and two[0] in b and thr[0] in b:
    ans = True
if one[1] in b and two[1] in b and thr[1] in b:
    ans = True
if one[2] in b and two[2] in b and thr[2] in b:
    ans = True

if one[0] in b and one[1] in b and one[2] in b:
    ans = True
if two[0] in b and two[1] in b and two[2] in b:
    ans = True
if thr[0] in b and thr[1] in b and thr[2] in b:
    ans = True

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

Solution (Python):
A1 = [int(a) for a in input().split()]
A2 = [int(a) for a in input().split()]
A3 = [int(a) for a in input().split()]
N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))
b_set = set(b)

set_list = [set(A1),
            set(A2),
            set(A3),
            set([A1[0], A2[0], A3[0]]),
            set([A1[1], A2[1], A3[1]]),
            set([A1[2], A2[2], A3[2]]),
            set([A1[0], A2[1], A3[2]]),
            set([A1[2], A2[1], A3[0]])]

f = False
for s in set_list:
    if len(s - b_set)==0:
        f = True
        print('Yes')
        break
if not f:
    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()))


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


result = False 


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

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


if not result:
    if A2[0][0]==1 and A2[1][1]==1 and A2[2][2]==1:
        result = True
    elif A2[0][2]==1 and A2[1][1]==1 and A2[2][0]==1:
        result = True


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

Solution (Python):
A = [list(map(int, input().split())) for _ in range(3)]
C=[0]*9
e=0
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):
          C[j*3+k]=1
          break
for j in range(3):
    if(C[j*3]==1 and C[j*3+1]==1 and C[j*3+2]==1):
         e=1
         break
    if(C[j]==1 and C[j+3]==1 and C[j+6]==1):
         e=1
         break
if(C[0]==1 and C[4]==1 and C[8]==1):
     e=1
if(C[2]==1 and C[4]==1 and C[6]==1):
     e=1
if(e==0):
  print("No")
else:
  print("Yes")

Solution (Python):
Bingo = [ list(map(int,input().split())) for i in range(3)]
n = int(input())
num = [int(input()) for i in range(n)]
Bingo.append([Bingo[0][0] , Bingo[1][1],Bingo[2][2] ])
Bingo.append([Bingo[0][2] , Bingo[1][1],Bingo[2][0] ])
for k in range(3):
  Bingo.append([Bingo[0][k] , Bingo[1][k],Bingo[2][k] ])
k=0
re = 'No'
for l in range(len(Bingo)):
  if len(list(set(num) & set(Bingo[l]))) == 3:
    re = 'Yes'
    break
print(re)

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


if b.count(a1[0])==1 and b.count(a1[1])==1 and b.count(a1[2])==1:
    print("Yes")
    exit()
if b.count(a2[0])==1 and b.count(a2[1])==1 and b.count(a2[2])==1:
    print("Yes")
    exit()
if b.count(a3[0])==1 and b.count(a3[1])==1 and b.count(a3[2])==1:
    print("Yes")
    exit()
if b.count(a1[0])==1 and b.count(a2[0])==1 and b.count(a3[0])==1:
    print("Yes")
    exit()
if b.count(a1[1])==1 and b.count(a2[1])==1 and b.count(a3[1])==1:
    print("Yes")
    exit()
if b.count(a1[2])==1 and b.count(a2[2])==1 and b.count(a3[2])==1:
    print("Yes")
    exit()
if b.count(a1[0])==1 and b.count(a2[1])==1 and b.count(a3[2])==1:
    print("Yes")
    exit()
if b.count(a1[2])==1 and b.count(a2[1])==1 and b.count(a3[0])==1:
    print("Yes")
    exit()

print("No")

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

for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] in B[k]:
                A[i][j] = 0
if A[0][0] == 0 and A[0][1] == 0 and A[0][2] == 0 or A[1][0] == 0 and A[1][1] == 0 and A[1][2] == 0 or A[2][0] == 0 and A[2][1] == 0 and A[2][2] == 0 or A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0 or A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0 or A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0 or A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0 or A[0][2] == 0 and A[1][1] == 0 and A[0][2] == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
  
bingo_card = []

for i in range(3):
    bingo_card.append(list(map(int, input().split())))
    
n = int(input())
called_num = set()
for i in range(n):
    called_num.add(int(input()))
    
    
for i in range(3):
    for j in range(3):
        if bingo_card[i][j] in called_num:
            bingo_card[i][j] = -1
            
bingo = False

if bingo_card[0][0] + bingo_card[0][1] + bingo_card[0][2] == -3:
    bingo = True
if bingo_card[1][0] + bingo_card[1][1] + bingo_card[1][2] == -3:
    bingo = True
if bingo_card[2][0] + bingo_card[2][1] + bingo_card[2][2] == -3:
    bingo = True
if bingo_card[0][0] + bingo_card[1][0] + bingo_card[2][0] == -3:
    bingo = True
if bingo_card[0][1] + bingo_card[1][1] + bingo_card[2][1] == -3:
    bingo = True
if bingo_card[0][2] + bingo_card[1][2] + bingo_card[2][2] == -3:
    bingo = True
if bingo_card[0][0] + bingo_card[1][1] + bingo_card[2][2] == -3:
    bingo = True
if bingo_card[2][0] + bingo_card[1][1] + bingo_card[0][2] == -3:
    bingo = True
    
if bingo:
    print('Yes')
else:
    print('No')

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

n = int(input())
b_s = []
for i in range(n):
    b_s.append(int(input()))
ans = "No"


for i in range(n):
    for j in range(3):
        for k in range(3):
            if b_s[i] == bingo[j][k]:
                bingo[j][k] = "o"

if bingo[1][1] == "o":
    if bingo[0][0] == "o" and bingo[2][2] == "o":
        ans = "Yes"
    elif bingo[0][2] == "o" and bingo[2][0] == "o":
        ans = "Yes"
    elif bingo[1][0] == "o" and bingo[1][2] == "o":
        ans = "Yes"
    elif bingo[0][1] == "o" and bingo[2][1] == "o":
        ans = "Yes"

elif bingo[1][1] != "o":
    if bingo[0][0] == "o" and bingo[0][1] == "o" and bingo[0][2] == "o":
        ans = "Yes"
    elif bingo[0][0] == "o" and bingo[1][0] == "o" and bingo[2][0] == "o":
        ans = "Yes"
    elif bingo[0][2] == "o" and bingo[1][2] == "o" and bingo[2][2] == "o":
        ans = "Yes"
    elif bingo[2][0] == "o" and bingo[2][1] == "o" and bingo[2][2] == "o":
        ans = "Yes"

print(ans)

Solution (Python):
import numpy as np

a = []
for _ in range(3):
    a.append([int(i) for i in input().split()])
a = [e for row in a for e in row]
for i in range(int(input())):
    b = int(input())
    if b in a:
        a[a.index(b)] = 0
bingo = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
flg = 0
for i in range(len(bingo)):
    c = 0
    for j in bingo[i]:
        c += a[j]
    if c==0:
        flg = 1
        break
print('Yes' if flg==1 else 'No')

Solution (Python):
hyo = []
x = []
ans = 0
for i in range(3):
    x = [int(e) for e in input().split()]
    hyo.extend(x)
    
kaz = int(input())

for j in range(kaz):
    num = int(input())
    for k in range(9):
        if hyo[k] == num:
            hyo[k] = 0
            break
for l in range(3):
    if hyo[3*l] == 0 and hyo[3*l+1] == 0 and hyo[3*l+2] == 0:
        ans = 1
    elif hyo[l] == 0 and hyo[3+l] == 0 and hyo[6+l] == 0:
        ans = 1
if hyo[0] ==0 and hyo[4] == 0 and hyo[8] == 0:
    ans =1
elif hyo[2] == 0 and hyo[4] == 0 and hyo[6] == 0:
    ans = 1
    
if ans == 1:
    print("Yes")
elif ans == 0:
    print("No")

Solution (Python):
def jud(l):
  for i in range(3):
    for j in range(3):
      if l[i][j] != 0:
        break
      if j == 2:
        return 1
  for i in range(3):
    for j in range(3):
      if l[j][i] != 0:
        break
      if j == 2:
        return 1
  for i in range(3):
      if l[i][i] != 0:
          break
      if i == 2:
          return 1
  for i in range(3):
      if l[i][2-i] != 0:
          break
      if i == 2:
          return 1
  return 0
          
       
def op(l,a):
  for i in range(3):
    for j in range(3):
      if l[i][j] == a:
        l[i][j] = 0
  return l

l = []
for i in range(3):
  l.append(input())
  l[i] = l[i].split()
  for j in range(3):
    l[i][j] = int(l[i][j])
num = int(input())
for i in range(num):
  a = int(input())
  l = op(l,a)
if jud(l) == 1:
  print('Yes')
else:
  print('No')

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

for i in range(N):
    for j in range(3):
        for k in range(3):
            if a[j][k] == b[i]:
                a[j][k] = 0
if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[2]) == 0:
    print("Yes")
elif a[0][0] + a[1][1] + a[2][2] == 0 or a[0][2] + a[1][1] + a[2][0] == 0:
    print("Yes")
elif a[0][0] + a[1][0] + a[2][0] == 0 or a[0][1] + a[1][1] + a[2][1] == 0 or a[0][2] + a[1][2] + a[2][2] == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
card = np.array([list(map(int,input().split())) for i in range(3)])
num = [int(input()) for i in range(int(input()))]

def check():
    if np.count_nonzero(card[0] == 0) == 3:
        return True
    elif np.count_nonzero(card[1] == 0) == 3:
        return True
    elif np.count_nonzero(card[2] == 0) == 3:
        return True
    elif np.count_nonzero(card.T[0] == 0) == 3:
        return True
    elif np.count_nonzero(card.T[1] == 0) == 3:
        return True
    elif np.count_nonzero(card.T[2] == 0) == 3:
        return True
    elif [card[0][0],card[1][1],card[2][2]].count(0) == 3:
        return True
    elif [card[0][2],card[1][1],card[2][0]].count(0) == 3:
        return True
for i in range(len(num)):
    for x in [0,1,2]:
        for y in [0,1,2]:
            if card[x][y] == num[i]:
                card[x][y] = 0
                if check():
                    print("Yes")
                    exit()

print("No")

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


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


A = read_matrix(3)

import numpy as np
A = np.array(A)
idx_dict = {}
for i in range(3):
    for j in range(3):
        idx_dict[A[i, j]] = (i, j)
N = read_a_int()
B = read_col(N, 1)[0]

for b in B:
    if b not in idx_dict.keys():
        continue
    i, j = idx_dict[b]
    A[i, j] = -1


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

if cnt == 3:
    print('Yes')
    exit()

if A[0, 1] == -1 and A[1, 1] == -1 and A[2, 0] == -1:
    print('Yes')
    exit()

print('No')

Solution (Python):
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a1=[0]*3
b1=[0]*3 
c1=[0]*3
n=int(input())
flag=0
for j in range(n):
  x=int(input())
  for i in range(3):
    if(a[i]==x):
      a1[i]=1
    elif(b[i]==x):
      b1[i]=1
    elif(c[i]==x):
      c1[i]=1 
  if(n>=3):
    s1,s2,s3=0,0,0
    cl1,cl2,cl3=0,0,0
    d1,d2=0,0
    d1=a1[0]+b1[1]+c1[2]
    d2=a1[2]+b1[1]+c1[0]
    for i in range(3):
      s1=s1+a1[i] 
      s2=s2+b1[i]
      s3=s3+c1[i]
      cl1=a1[i]+b1[i]+c1[i]
      if(cl1==3 or s1==3 or s2==3 or s3==3 or d1==3 or d2==3):
        flag=1 
        break
if(flag==0):
  print("No")
else:
  print("Yes")

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

for x in b:
    for i in range(3):
        for j in range(3):
            if a[i][j] == x:
                a[i][j] = 'x'
for x in range(3):
    if (a[x][0] == a[x][1] == a[x][2] == 'x') or (a[0][x] == a[1][x] == a[2][x] == 'x'):
        print('Yes')
        exit()
if (a[0][0] == a[1][1] == a[2][2] == 'x') or (a[0][2] == a[1][1] == a[2][0] == 'x'):
    print('Yes')
    exit()
print('No')

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

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

for j in range(N):
  if B[j] in A:
    A[A.index(B[j])] = 0
ans = 'No'

for k in range(3):
  if A[k] == A[k+3] == A[k+6]:
    ans = 'Yes'
  elif A[3*k] == A[3*k+1] == A[3*k+2]:
    ans = 'Yes'
  elif A [0] == A[4] == A[8]:
    ans = 'Yes'
  elif A [2] == A[4] == A[6]:
    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 = []
for i in range(N):
    inputItem = int(input())
    b.append(inputItem)
check = {'first':[False,False,False],'second':[False,False,False],'third':[False,False,False]}
for j in b:
    if j in A1:
        pos = A1.index(j)
        check['first'][pos] = True
    elif j in A2:
        pos = A2.index(j)
        check['second'][pos] = True
    elif j in A3:
        pos = A3.index(j)
        check['third'][pos] = True

bingo = False
for k in range(3):
    if check['first'][k]==check['second'][k]==check['third'][k]==True:
        bingo = True
        break
if check['first'][0]==check['first'][1]==check['first'][2]==True:
    bingo = True
elif check['second'][0]==check['second'][1]==check['second'][2]==True:
    bingo = True
elif check['third'][0]==check['third'][1]==check['third'][2]==True:
    bingo = True
if check['first'][0]==check['second'][1]==check['third'][2]==True or check['first'][2]==check['second'][1]==check['third'][0]==True:
    bingo = True
if bingo:
    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())
b = []
for i in range(N):
    b.append(int(input()))
bingo = False
if A[0] in b:
    if A[1] in b:
        if A[2] in b:
            bingo = True

if B[0] in b:
    if B[1] in b:
        if B[2] in b:
            bingo = True


if C[0] in b:
    if C[1] in b:
        if C[2] in b:
            bingo = True

if A[0] in b:
    if B[1] in b:
        if C[2] in b:
            bingo = True


if A[2] in b:
    if B[1] in b:
        if C[0] in b:
            bingo = True

if A[0] in b:
    if B[0] in b:
        if C[0] in b:
            bingo = True

if A[1] in b:
    if B[1] in b:
        if C[1] in b:
            bingo = True

if A[2] in b:
    if B[2] in b:
        if C[2] in b:
            bingo = True

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

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

n = int(input())

b_list = []
count_list = []

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

for i in range(3):
    for j in range(3):
        for b in b_list:
            if a[i][j] == b:
                count_list.append(str(i) + str(j))

if ((("00" in count_list) and ("01" in count_list) and ("02" in count_list)) or
   (("10" in count_list) and ("11" in count_list) and ("12" in count_list)) or
   (("20" in count_list) and ("21" in count_list) and ("22" in count_list))):
        print("Yes")
elif ((("00" in count_list) and ("10" in count_list) and ("20" in count_list)) or
   (("01" in count_list) and ("11" in count_list) and ("21" in count_list)) or
   (("02" in count_list) and ("12" in count_list) and ("22" in count_list))):
        print("Yes")
elif ((("00" in count_list) and ("11" in count_list) and ("22" in count_list)) or
   (("02" in count_list) and ("11" in count_list) and ("20" in count_list))):
        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=[]
for i in range(n):
    c = int(input())
    b.append(c)
ref = [[0]*3 for i in range(3)]
for i in b:
    if i in a1:
        j = a1.index(i)
        ref[0][j] = 1
    elif i in a2:
        j = a2.index(i)
        ref[1][j] = 1
    elif i in a3:
        j = a3.index(i)
        ref[2][j] = 1
    else: pass

if sum(ref[0])==3 or sum(ref[1])==3 or sum(ref[2])==3:
    print("Yes")
elif ref[0][0]+ref[1][0]+ref[2][0]==3:
    print("Yes")
elif ref[0][1]+ref[1][1]+ref[2][1]==3:
    print("Yes")
elif ref[0][2]+ref[1][2]+ref[2][2]==3:
    print("Yes")
elif ref[0][0]+ref[1][1]+ref[2][2]==3:
    print("Yes")
elif ref[0][2]+ref[1][1]+ref[2][0]==3:
    print("Yes")
else:
    print("No")

Solution (Python):
A = []
A.append(list(map(lambda x: int(x), input().split())))
A.append(list(map(lambda x: int(x), input().split())))
A.append(list(map(lambda x: int(x), input().split())))

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

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

for number in numbers:
  for y in range(3):
    
    if number in A[y]:
      answers[y][A[y].index(number)] = True 

flg = False


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


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


if answers[0][0] and answers[1][1] and answers[2][2]:
  flg = True

if answers[2][0] and answers[1][1] and answers[0][2]:
  flg = True

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

Solution (Python):
from collections import defaultdict as dd
a = []
for _ in range(3):
  temp = list(map(int,input().split()))
  a.append(temp)
  
m1 = dd(int)
n = int(input())

for _ in range(n):
  temp = int(input())
  m1[temp]+=1
  
cnt=0
flag=0
for i in range(3):
  cnt=0
  for j in range(3):
    if m1[a[i][j]]==1:
      cnt+=1
  if cnt==3:
    print("Yes")
    flag=1
    break

if flag==0:
  for i in range(3):
    cnt=0
    for j in range(3):
      if m1[a[j][i]]==1:
        cnt+=1
        
    if cnt==3:
      print("Yes")
      flag=1
      break
      
if flag==0:
  cnt=0
  for i in range(3):
    if m1[a[i][i]]==1:
      cnt+=1
  if cnt==3:
    print("Yes")
    flag=1
    
if flag==0:
  cnt=0;j=2
  for i in range(3):
    if m1[a[i][j]]==1:
      cnt+=1
    j-=1
  if cnt==3:
    print("Yes")
    flag=1
    
if flag==0:
  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(len(b)):
    for j in range(len(a)):
        for k in range(3):
            if b[i]==a[j][k]:
                a[j][k]='o'
ans=0
for i in range(3):
    if a[i][0]=='o' and a[i][1]=='o' and a[i][2]=='o':
        ans+=1
    if a[0][i]=='o' and a[1][i]=='o' and a[2][i]=='o':
        ans+=1
if a[0][0]=='o' and a[1][1]=='o' and a[2][2]=='o':
    ans+=1
if a[0][2]=='o' and a[1][1]=='o' and a[2][0]=='o':
    ans+=1
if ans>=1:
    print('Yes')
else:
    print('No')

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

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

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



                
for i in range(3):
    for j in range(3):
        if a_true[i][j] == False:
            bingo = False
            break
    if bingo == True:
        
        print('Yes')
        exit()
    bingo = True

bingo = True

for i in range(3):
    for j in range(3):
        if a_true[j][i] == False:
            bingo = False
            break
    if bingo == True:
        print('Yes')
        exit()
    bingo = True

if a_true[1][1] == True:
    if a_true[0][0] == True:
        if a_true[2][2] == True:
            print('Yes')
            exit()
    elif a_true[0][2] == True:
        if a_true[2][0] == True:
            print('Yes')
            exit()
else:
    print('No')
    exit()

print('No')

Solution (Python):


A_List_1 = list(map(int,input().split()))
A_List_2 = list(map(int,input().split()))
A_List_3 = list(map(int,input().split()))



N = int(input())

for i in range(N):
    n = int(input())
    for j in range(3):
        if n == A_List_1[j]:
            A_List_1[j] = 0
        if n == A_List_2[j]:
            A_List_2[j] = 0
        if n == A_List_3[j]:
            A_List_3[j] = 0


sum_1 = A_List_1[0] + A_List_1[1] + A_List_1[2]
sum_2 = A_List_2[0] + A_List_2[1] + A_List_2[2]
sum_3 = A_List_3[0] + A_List_3[1] + A_List_3[2]
naname_1 = A_List_1[0] + A_List_2[1] + A_List_3[2]
naname_2 = A_List_1[2] + A_List_2[1] + A_List_3[0]
tate_0 = A_List_1[0] + A_List_2[0] + A_List_3[0]
tate_1 = A_List_1[1] + A_List_2[1] + A_List_3[1]
tate_2 = A_List_1[2] + A_List_2[2] + A_List_3[2]

if sum_1 == 0 or sum_2 == 0 or sum_3 == 0 or naname_1 == 0 or naname_2 == 0 or tate_0 == 0 or tate_1 == 0 or tate_2 == 0:
    print('Yes')
else:
    print('No')

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



A_new = []
for bi in b:
  
  for i in range(3):
    
    A_ = [0 if bi==A[i][j] else A[i][j] for j in range(3)]
    
    A[i] = A_

import numpy as np
A = np.array(A)
t = np.sum(A, axis=0)
y = np.sum(A, axis=1)
n1 = A[0][0]+A[1][1]+A[2][2]
n2 = A[0][2]+A[1][1]+A[2][0]

if 0 in t:
  print('Yes')
elif 0 in y:
  print('Yes')
elif n1==0 or n2==0:
  print('Yes')
else:
  print('No')