Problem:
 Score : 200 points    Problem Statement We have a bingo card with a 3\times3 grid. The square at the i -th row from the top and the j -th column from the left contains the number A_{i, j} .  The MC will choose N numbers, b_1, b_2, \cdots, b_N . If our bingo sheet contains some of those numbers, we will mark them on our sheet.  Determine whether we will have a bingo when the N numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.      Constraints  All values in input are integers.  1 \leq A_{i, j} \leq 100  A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))  1 \leq N \leq 10  1 \leq b_i \leq 100  b_i \neq b_j (i \neq j)         Input Input is given from Standard Input in the following format:  A_{1, 1}  A_{1, 2}  A_{1, 3}  A_{2, 1}  A_{2, 2}  A_{2, 3}  A_{3, 1}  A_{3, 2}  A_{3, 3}  N  b_1  \vdots  b_N       Output If we will have a bingo, print Yes ; otherwise, print No .        Sample Input 1 84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30      Sample Output 1 Yes  We will mark A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3} , and complete the diagonal from the top-left to the bottom-right.       Sample Input 2 41 7 46
26 89 2
78 92 8
5
6
45
16
57
17      Sample Output 2 No  We will mark nothing.       Sample Input 3 60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34      Sample Output 3 Yes  We will mark all the squares.

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

flag = False
for row in A:
    if all(item in bn for item in row):
        flag = True

for col in zip(*A):
    if all(item in bn for item in col):
        flag = True

if all(A[i][i] in bn for i in range(3)):
    flag = True

if all(A[i][3-1-i] in bn for i in range(3)):
    flag = True

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

Solution (Python):
import sys
a = [[int(j) for j in input().split()] for i in range(3)]
n = int(input())
for i in range(n):
    n = int(input())
    for j in range(3):
        for k in range(3):
            if(a[j][k] == n):
                a[j][k] = "."

for i in range(3):
    if(a[i] == [".", ".", "."] or (a[0][i] == a[1][i]
    and a[2][i]) == "."):
        print("Yes")
        sys.exit()

if(a[0][0] == a[1][1] and a[2][2] == "." or (a[0][2] == a[1][1] and a[2][0] == ".")):
    print("Yes")
    sys.exit()

print("No")

Solution (Python):
A = [[int(a) for a in input().split(" ")] for i in range(3)]
N = int(input())
for _ in range(N):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if A[i][j] == b:
        A[i][j] = 0
        
bingo = False

for i in range(3):
  bingo |= (A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0)

for j in range(3):
  bingo |= (A[0][j] == 0 and A[1][j] == 0 and A[2][j] == 0)

bingo |= (A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0)
bingo |= (A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0)

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

Solution (Python):
BINGO_ROW_NO = 3

A  = []
for i in range(BINGO_ROW_NO):
    A.append(input().split())

N = int(input())



def SetBingo(A, b):
    for y in range(BINGO_ROW_NO):
        for x in range(BINGO_ROW_NO):
            if A[y][x] == b:
                A[y][x] = ''
                return 
    return 

for _ in range(N):
    b = input()
    SetBingo(A, b)

isBingo = False


for i in range(BINGO_ROW_NO):
    if A[i][0] == '' and A[i][1] == '' and A[i][2] == '':
        isBingo = True

for i in range(BINGO_ROW_NO):
    if A[0][i] == '' and A[1][i] == '' and A[2][i] == '':
        isBingo = True

if A[0][0] == '' and A[1][1] == '' and A[2][2] == '':
    isBingo = True

if A[0][2] == '' and A[1][1] == '' and A[2][0] == '':
    isBingo = True

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

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

po = [-1 for i in range(101)]

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

for i in range(3):
    b = l()
    for j in range(3):
        po[b[j]] = i*3 + j

n = onem()

for i in range(n):
    o = onem()
    if po[o] != -1:
        a[po[o]//3][po[o]%3] = 1

fl = False

for i in range(3):
    if sum(a[i]) == 3:
        fl = True

for i in range(3):
    if a[0][i] + a[1][i] + a[2][i]== 3:
        fl = True

if a[0][0] + a[1][1] + a[2][2] == 3:
    fl = True

if a[0][2] + a[1][1] + a[2][0] == 3:
    fl = True

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

Solution (Python):
bingonum=[[0,0,0],[0,0,0],[0,0,0]]
bingo=[["False","False","False"],["False","False","False"],["False","False","False"]]
for i in range(3):
    bingonum[i][0],bingonum[i][1],bingonum[i][2] = map(int,input().split())

N = int(input())
b=[]
for _ in range(N):
    b.append(int(input()))
for x in range(N):
    for i in range(3):
        for j in range(3):
            if bingonum[i][j]==b[x]:
                bingo[i][j]="True"

IsBingo = "No"
for i in range(3):
    if bingo[i][0] =="True" and bingo[i][1] =="True" and bingo[i][2] =="True":
        IsBingo="Yes"
    if bingo[0][i] =="True" and bingo[1][i] =="True" and bingo[2][i] =="True":
        IsBingo="Yes"
if (bingo[0][0] =="True" and bingo[1][1] =="True" and bingo[2][2] =="True") or (bingo[0][2] =="True" and bingo[1][1] =="True" and bingo[2][0]=="True"):
    IsBingo="Yes"
print(IsBingo)

Solution (Python):


bingonum=[[0,0,0],[0,0,0],[0,0,0]]
bingo=[["False","False","False"],["False","False","False"],["False","False","False"]]
for i in range(3):
    bingonum[i][0],bingonum[i][1],bingonum[i][2] = map(int,input().split())

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

for x in range(N):
    for i in range(3):
        for j in range(3):
            if bingonum[i][j]==b[x]:
                bingo[i][j]="True"

IsBingo = "No"
for i in range(3):
    if bingo[i][0] =="True" and bingo[i][1] =="True" and bingo[i][2] =="True":
        IsBingo="Yes"
    elif bingo[0][i] =="True" and bingo[1][i] =="True" and bingo[2][i] =="True":
        IsBingo="Yes"
if (bingo[0][0] =="True" and bingo[1][1] =="True" and bingo[2][2] =="True") or (bingo[0][2] =="True" and bingo[1][1] =="True" and bingo[2][0]=="True"):
    IsBingo="Yes"
print(IsBingo)

Solution (Python):


bingonum=[[0,0,0],[0,0,0],[0,0,0]]
bingo=[["False","False","False"],["False","False","False"],["False","False","False"]]
for i in range(3):
    bingonum[i][0],bingonum[i][1],bingonum[i][2] = map(int,input().split())

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

for x in range(N):
    for i in range(3):
        for j in range(3):
            if bingonum[i][j]==b[x]:
                bingo[i][j]="True"

IsBingo = "No"
for i in range(3):
    if bingo[i][0] =="True" and bingo[i][1] =="True" and bingo[i][2] =="True":
        IsBingo="Yes"
    if bingo[0][i] =="True" and bingo[1][i] =="True" and bingo[2][i] =="True":
        IsBingo="Yes"
if (bingo[0][0] =="True" and bingo[1][1] =="True" and bingo[2][2] =="True") or (bingo[0][2] =="True" and bingo[1][1] =="True" and bingo[2][0]=="True"):
    IsBingo="Yes"
print(IsBingo)

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

for k in range(3):
  if sum(A[k][:])==0:
    print('Yes')
    exit(0)

ri = [[a[k] for a in A]for k in range(3)]

for k in range(3):
  if sum(ri[:][k])==0:
    print('Yes')
    exit(0)
    
if (A[0][0]+A[1][1]+A[2][2]==0)or(A[2][0]+A[1][1]+A[0][2]==0): 
    print('Yes')
    exit(0)
    
print('No')

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

for k in range(3):
  if A[k][:]==[-1,-1,-1]:
    print('Yes')
    exit(0)

ri = [[_[k] for _ in A]for k in range(3)]

for k in range(3):
  if ri[:][k]==[-1,-1,-1]:
    print('Yes')
    exit(0)
    
if (A[0][0]==A[1][1]==A[2][2]==-1)or(A[2][0]==A[1][1]==A[0][2]==-1): 
    print('Yes')
    exit(0)
    
print('No')

Solution (Python):
def main():
    import numpy as np

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

    is_bingo = False
    is_row_bingo = np.sum(card, axis=0).min() == 0
    is_column_bingo = np.sum(card, axis=1).min() == 0
    is_diag_bingo1 = np.sum(np.diag(card)) == 0
    is_diag_bingo2 = np.sum(np.diag(np.fliplr(card))) == 0

    print('Yes' if is_row_bingo or is_column_bingo or is_diag_bingo1 or is_diag_bingo2 else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
import sys

def hantei(h1, h2, h3):
    if h1 is True and h2 is True and h3 is True:
        return True
    else:
        return False


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

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

for i in range(3):
    if hantei(A[i][0], A[i][1], A[i][2]):
        print("Yes")
        sys.exit()
    elif hantei(A[0][i], A[1][i], A[2][i]):
        print("Yes")
        sys.exit()

if hantei(A[0][0], A[1][1], A[2][2]) or hantei(A[0][2], A[1][1], A[2][0]):
    print("Yes")
    sys.exit()

print("No")

Solution (Python):

A = []
for _ in range(3):
    temp = [int(s) for s in input().split()]
    A += temp


N = int(input())


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


R = [False] * 9
for i, n in enumerate(A):
    R[i] = n in b_list


def check_bingo(table, check_index):
    for i in check_index:
        if not table[i]:
            return False
    return True

def check_table(table):
    check_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],
    ]

    for check_index in check_list:
        if check_bingo(table, check_index):
            return True
    return False


result = "Yes" if check_table(R) else "No"
print(result)

Solution (Python):
a0, a1, a2 = map(int, input().split())
b0, b1, b2 = map(int, input().split())
c0, c1, c2 = map(int, input().split())
yoko0 = [a0, a1, a2]
yoko1 = [b0, b1, b2]
yoko2 = [c0, c1, c2]
tate0 = [a0, b0, c0]
tate1 = [a1, b1, c1]
tate2 = [a2, b2, c2]
naname0 = [a0, b1, c2]
naname1 = [a2, b1, c0]
n = int(input())
for i in range(n):
    m = int(input())
    if m in yoko0:
        yoko0.remove(m)
    if m in yoko1:
        yoko1.remove(m)
    if m in yoko2:
        yoko2.remove(m)
    if m in tate0:
        tate0.remove(m)
    if m in tate1:
        tate1.remove(m)
    if m in tate2:
        tate2.remove(m)
    if m in naname0:
        naname0.remove(m)
    if m in naname1:
        naname1.remove(m)
if yoko0 == [] or yoko1 == [] or yoko2 == [] or tate0 == [] or tate1 == [] or tate2 == [] or naname0 == [] or naname1 == []:
    print("Yes")
else:
    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()))
N=int(input())
b=list(int(input()) for i in range(N))

for i in range(N):
    for j in range(3):
        if b[i] == A_1[j]:
            A_1[j]=0
        elif b[i] == A_2[j]:
            A_2[j]=0
        elif b[i] == A_3[j]:
            A_3[j]=0

A=A_1+A_2+A_3
if A[0]==A[1] and A[0]==A[2]:
    print('Yes')
elif A[3]==A[4] and A[3]==A[5]:
    print('Yes')
elif A[6]==A[7] and A[6]==A[8]:
    print('Yes')
elif A[0]==A[4] and A[0]==A[8]:
    print('Yes')
elif A[2]==A[4] and A[2]==A[6]:
    print('Yes')
elif A[0]==A[3] and A[0]==A[6]:
    print('Yes')
elif A[1]==A[4] and A[1]==A[7]:
    print('Yes')
elif A[2]==A[5] and A[2]==A[8]:
    print('Yes')
else:
    print('No')

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

card = [[0, 0, 0],
              [0, 0, 0],
              [0, 0, 0]]
bingo  = False


for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            card[i][j] = 1



for i in range(3):
    if sum(card[i])==3:
        bingo = True
        break
    if (card[0][i]+card[1][i]+card[2][i])==3:
        bingo = True
        break


if ~bingo and card[1][1]==1:
    if card[0][0] == 1 and card[2][2]==1:
        bingo = True
    if card[0][2] == 1 and card[2][0]==1:
        bingo = True
if bingo:
    print('Yes')
else:
    print('No')

Solution (Python):
from itertools import combinations as comb

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

bingo = [[8, 1, 6], [3, 5, 7], [4, 9, 2]]
check = []

for i in range(N):
    for j in range(3):
        if b[i] == A1[j]:
            check.append(bingo[0][j])
            break
        elif b[i] == A2[j]:
            check.append(bingo[1][j])
            break
        elif b[i] == A3[j]:
            check.append(bingo[2][j])
            break

flag = False
for i in list(comb(check, 3)):
    if sum(i) == 15:
        flag = True
        break

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

Solution (Python):
a1,a2,a3 = map(int, input().split())
a4,a5,a6 = map(int, input().split())
a7,a8,a9 = map(int, input().split())
n = int(input())
b = [int(input()) for i in range(n)]
a = [a1,a2,a3,a4,a5,a6,a7,a8,a9]
for i in range(9):
    if a[i] in b:
        a[i] = 0
if a[0:3] ==[0,0,0] or a[3:6] ==[0,0,0] or a[6:9] ==[0,0,0] or [a[0],a[3],a[6]] ==[0,0,0] or [a[1],a[4],a[7]]==[0,0,0] or [a[2],a[5],a[8]]==[0,0,0] or [a[0],a[4],a[8]]==[0,0,0] or [a[2],a[4],a[6]]==[0,0,0]:
    print('Yes')
else:
    print('No')

Solution (Python):

import math


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

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

    for i, row in enumerate(bingo_card_number):
        for j, cell in enumerate(row):
            if cell in number_called:
                bingo_card[i][j] = 1

    result = "No"
    for i in range(3):

        if sum(bingo_card[i]) == 3:
            result = "Yes"

        if bingo_card[0][i] + bingo_card[1][i] + bingo_card[2][i] == 3:
            result = "Yes"

    if bingo_card[0][0] + bingo_card[1][1] + bingo_card[2][2] == 3\
        or bingo_card[2][0] + bingo_card[1][1] + bingo_card[0][2] == 3:
        result = "Yes"


    print(result)


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np


def main():
    bingo_card = np.array([list(map(int, input().split())) for _ in range(3)])
    counter = int(input())

    for _ in range(counter):
        bingo_card = np.where(bingo_card == int(input()), 0, bingo_card)

    vertical_bingo = min(np.sum(bingo_card, axis=0)) == 0
    horizontal_bingo = min(np.sum(bingo_card, axis=1)) == 0

    diag_normal_bingo = bingo_card[0][0] == 0 and bingo_card[1][1] == 0 and bingo_card[2][2] == 0
    diag_reverse_bingo = bingo_card[0][2] == 0 and bingo_card[1][1] == 0 and bingo_card[2][0] == 0

    if vertical_bingo or horizontal_bingo or diag_normal_bingo or diag_reverse_bingo:
        print('Yes')
        exit()
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):

a = sum([input().split() for i in range(3)], [])

a = [int(i) for i in a]
count = int(input())
if count < 3:
    print("No")
else:
    num = int(input())
    a = [-1 if int(i) == num else i for i in a]
    num = int(input())
    a = [-1 if int(i) == num else i for i in a]
    counter = 3
    d = False
    while (counter <= count):
        counter += 1
        num = int(input())
        a = [-1 if int(i) == num else i for i in a]
        point = sum(i == -1 for i in a)
        if point >= 3 and (sum(a[0:3]) == -3 or sum(a[3:6]) == -3 or sum(a[6:9]) == -3 or sum(a[0::3]) == -3 or sum(
                a[1::3]) == -3 or sum(a[2::3]) == -3 or sum(a[0::4]) == -3 or sum(a[2:7:2]) == -3):
            print("Yes")
            d = True
            break
    if not d:
        print("No")

Solution (Python):
Size = 3

A = [list(input().split()) for _ in range(Size)]
n = int(input())
b = [input() for _ in range(n)]

bingo = False
for row in A:
    if all(item in b for item in row):
        bingo = True
for col in zip(*A):
    if all(item in b for item in col):
        bingo = True
if all(A[i][i] in b for i in range(Size)):
    bingo = True
if all(A[i][Size - 1 - i] in b for i in range(Size)):
    bingo = True

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

Solution (Python):
Size = 3

A = [list(map(int, input().split())) for _ in range(Size)]
n = int(input())

for _ in range(n):
    b = int(input())
    for i in range(Size):
        for j in range(Size):
            if A[i][j] == b:
                A[i][j] = 0

bingo = False
for row in A:
    if sum(row) == 0:
        bingo = True
for col in zip(*A):
    if sum(col) == 0:
        bingo = True
if sum(A[i][i] for i in range(Size)) == 0:
    bingo = True
if sum(A[i][Size - 1 - i] for i in range(Size)) == 0:
    bingo = True

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

Solution (Python):
import sys
A1=map(int, sys.stdin.readline().split())
A2=map(int, sys.stdin.readline().split())
A3=map(int, sys.stdin.readline().split())
A=A1+A2+A3
N=input()

def isbingo():
    if A[0]==A[1]==A[2]==0: return True
    elif A[3]==A[4]==A[5]==0: return True
    elif A[6]==A[7]==A[8]==0: return True
    elif A[0]==A[3]==A[6]==0: return True
    elif A[1]==A[4]==A[7]==0: return True
    elif A[2]==A[5]==A[8]==0: return True
    elif A[0]==A[4]==A[8]==0: return True
    elif A[2]==A[4]==A[6]==0: return True
    else: return False

for _ in range(N):
    b=int(sys.stdin.readline().strip())
    for i,a in enumerate(A):
        if b==a:
            A[i]=0

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

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

n = int(input())

for _ in range(n):
    b = input()
    for i in range(3):
        if b == a1[i]:
            a1[i] = 0
        if b == a2[i]:
            a2[i] = 0
        if b == a3[i]:
            a3[i] = 0
        
if a1[0]==0 and a1[1]==0 and a1[2]==0:
    print('Yes')
elif a2[0]==0 and a2[1]==0 and a2[2]==0:
    print('Yes')
elif a3[0]==0 and a3[1]==0 and a3[2]==0:
    print('Yes')
elif a1[0]==0 and a2[0]==0 and a3[0]==0:
    print('Yes')
elif a1[1]==0 and a2[1]==0 and a3[1]==0:
    print('Yes')
elif a1[2]==0 and a2[2]==0 and a3[2]==0:
    print('Yes')
elif a1[0]==0 and a2[1]==0 and a3[2]==0:
    print('Yes')
elif a1[2]==0 and a2[1]==0 and a3[0]==0:
    print('Yes')
else:
    print('No')

Solution (Python):
A = []
A_1 = list(map(int,input().split()))
A_2 = list(map(int,input().split()))
A_3 = list(map(int,input().split()))
A.append(A_1)
A.append(A_2)
A.append(A_3)
B = []
check=0
BingocountR=0
BingocountG=0
N = int(input())
ArrayBingo =[[0,0,0],[0,0,0],[0,0,0]]
for i in range(N):
    B.append(int(input()))
for j in range (3):
    for k in range (3):
        for l in range (N):
            if A[j][k]==B[l]:
                ArrayBingo[j][k]=1
for i in range(3):
    for j in range(3):
        if ArrayBingo[j][i]==1:
            BingocountR+=1
            if BingocountR ==3:
                check+=1
    BingocountR = 0
for i in range(3):
    for j in range(3):
        if ArrayBingo[i][j]==1:
            BingocountG+=1
            if BingocountG ==3:
                check+=1
    BingocountG = 0
if (ArrayBingo[0][0] == 1 and ArrayBingo[1][1] == 1 and ArrayBingo [2][2] == 1) or (ArrayBingo[0][2] == 1 and ArrayBingo[1][1] == 1 and ArrayBingo [2][0] == 1):
    check += 1
if check>0:
    print('Yes')
else:
    print('No')

Solution (Python):
bingo = []
is_bingo = False
for i in range(3):
    bingo.append(list(map(int, input().split())))
for i in range(3):
    bingo.append([bingo[j][i] for j in range(3)])
bingo.append([bingo[i][i] for i in range(3)])
bingo.append([bingo[i][2-i] for i in range(3)])
n = int(input())
result = set()
for i in range(n):
    result.add(int(input()))
for i in bingo:
    if set(i).issubset(result):
        print('Yes')
        is_bingo = True
        break
if not is_bingo:
    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 x in b:
    for i,a in enumerate(A):
        if x in a:
            A[i][a.index(x)] = 0
for i in range(3):
    if A[i][0]+A[i][1]+A[i][2] == 0 or A[0][i]+A[1][i]+A[2][i] == 0:
        print("Yes")
        exit()

if A[0][0]+A[1][1]+A[2][2] == 0 or A[0][2]+A[1][1]+A[2][0] == 0:
    print("Yes")
    exit()
    
print("No")

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


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

hole=set()
for num in b:
    for i in range(9):
        if num==A[i]:
            hole.add(i)

for tri in BINGO:

    if tri <= hole:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
import sys

a = [[0]*3 for _ in range(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())
f = [[False]*3 for _ in range(3)]
for _ in range(n):
  b = int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j] == b:
        f[i][j] = True

for i in range(3):
  if (f[i][0] and f[i][1] and f[i][2]):
    print("Yes")
    sys.exit()
  if (f[0][i] and f[1][i] and f[2][i]):
    print("Yes")
    sys.exit()
if ((f[0][0] and f[1][1] and f[2][2]) or (f[0][2] and f[1][1] and f[2][0])):
  print("Yes")
else:
  print("No")

Solution (Python):
A = []
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
A.append(A_1)
A.append(A_2)
A.append(A_3)

N = int(input())
b = []

for i in range(N):
    b.append(int(input()))

c = [[0,0,0],[0,0,0],[0,0,0]]
for j in range(N):
    for p in range(3):
        for l in range(3):
            if b[j] == A[p][l]:
                c[p][l] = 1

check = 0
for d in range(N):
    for o in range(3):
        if c[o][0] == 1 and c[o][1] == 1 and c[o][2] == 1:
            check += 1
            break

    for g in range(3):
        if c[0][g] == 1 and c[1][g] == 1 and c[2][g] == 1:
            check += 1
            break

    if c[0][0] == 1 and c[1][1] == 1 and c[2][2] == 1:
        check += 1
    if c[0][2] == 1 and c[1][1] == 1 and c[2][0] == 1:
        check += 1
    if check != 0:
        break

if check != 0:
    print('Yes')
else :
    print('No')

Solution (Python):
a,b,c=input().split()
d,e,f=input().split()
g,h,i=input().split()

loopin=input()

A11,A12,A13,A21,A22,A23,A31,A32,A33=0,0,0,0,0,0,0,0,0


for x in range(int(loopin)):
	bingo = input()
	if bingo==a:
		A11=1
	elif bingo==b:
		A12=1	
	elif bingo==c:
		A13=1	
	elif bingo==d:
		A21=1	
	elif bingo==e:
		A22=1	
	elif bingo==f:
		A23=1	
	elif bingo==g:
		A31=1	
	elif bingo==h:
		A32=1
	elif bingo==i:
		A33=1


if (A11+A12+A13)==3:
	print("Yes")
elif (A21+A22+A23)==3:
	print("Yes")
elif (A31+A32+A33)==3:
	print("Yes")
elif (A11+A21+A31)==3:
	print("Yes")
elif (A12+A22+A32)==3:
	print("Yes")
elif (A13+A23+A33)==3:
	print("Yes")
elif (A11+A22+A33)==3:
	print("Yes")
elif (A13+A22+A31)==3:
	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 = [[0,0,0],
     [0,0,0],
     [0,0,0]]
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            c[i][j] = 1

flag = 0
for i in range(3):
    if c[i] == [1,1,1]:
        flag = 1
for i in range(3):
    if c[0][i] == c[1][i] == c[2][i] == 1:
        flag = 1
if c[0][0] == c[1][1] == c[2][2] == 1:
    flag = 1
if c[2][0] == c[1][1] == c[0][2] == 1:
    flag = 1

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

Solution (Python):
A = []
for i in range(3):
    a1,a2,a3 = list(map(int,input().split()))
    Ai = [a1,a2,a3]
    A.extend(Ai)
n = int(input())
ana = []
for i in range(n):
    b = int(input())
    if b in A:
        idx = A.index(b)
        ana.append(idx)
atari = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
judje = False
for i in range(len(atari)):
    if (atari[i][0] in ana and atari[i][1] in ana)  and atari[i][2] in ana:
        judje = True
        break
if judje == True:    
    print("Yes")
else:
    print("No")

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import defaultdict

a = nan(3)
d = [[0] * 3 for _ in range(3)]
n = ni()
b = nin(n)
dic = defaultdict(int)

for i in range(n):
    dic[b[i]] += 1

for i in range(3):
    for j in range(3):
        d[i][j] = dic[a[i][j]] >= 1

flag = False
for i in range(3):
    cnt = 0
    for j in range(3):
        cnt += d[i][j]
    if cnt == 3:
        flag = True

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

cnt_r = 0
cnt_l = 0
for j in range(3):
    cnt_r += d[j][j]
    cnt_l += d[j][3 - j - 1]
if cnt_r == 3 or cnt_l == 3:
    flag = True

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

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

def check(card):
    if (card[0][0] == card[0][1] == card[0][2] == 'x') or (card[1][0] == card[1][1] == card[1][2] == 'x') or (card[2][0] == card[2][1] == card[2][2] == 'x'):
        return 'Yes'
    elif (card[0][0] == card[1][0] == card[2][0] == 'x') or (card[0][1] == card[1][1] == card[2][1] == 'x') or (card[0][2] == card[1][2] == card[2][2] == 'x'):
        return 'Yes'
    elif (card[0][0] == card[1][1] == card[2][2] == 'x') or (card[0][2] == card[1][1] == card[2][0] == 'x'):
        return 'Yes'
    else:
        return 'No'

for a in number:
    for b in bingo:
        for c in b:
            if a == c:
                bingo[bingo.index(b)][bingo[bingo.index(b)].index(c)] = 'x'

print(check(bingo))

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

n = int(input())

def bg(a):
    f = False
    for i in range(3):
        t = 0
        for j in range(3):
            t += a[i][j]
        if t== 3:
            f = True

    for i in range(3):
        t = 0
        for j in range(3):
            t += a[j][i]
        if t== 3:
            f = True
    t = 0
    s = 0
    for i in range(3):
        t += a[i][i]
        s += a[i][-i-1]
    if t==3 or s ==3:
        f = True
    return f
ma = [[0]*3 for i in range(3)]
for c in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                ma[i][j] = 1
if bg(ma):
    print("Yes")
else:
    print("No")

Solution (Python):


import numpy as np

A = np.zeros((3,3), dtype=np.int64)

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

N = int(input())

for _ in range(N):
    b = int(input())
    A = np.where(A==b, 0, A)

if sum(A[0])==0 or sum(A[1])==0 or sum(A[2])==0 or \
    sum(A[:,0])==0 or sum(A[:,1])==0 or sum(A[:,2])==0 or \
    A[0,0]+A[1,1]+A[2,2]==0 or \
    A[2,0]+A[1,1]+A[0,2]==0:
    print('Yes')
else:
    print('No')

Solution (Python):
List = [list(map(int,input().split())) for i in range (3)]
N = int(input())
Number = [int(input()) for i in range (N)]
a = 'No'
for k in range(0,3):
    for j in range(0,3):
        for i in range(0,N):
            if Number[i]== List[k][j]:
                List[k][j]=0
            
if List[0] == [0,0,0] or List[1] == [0,0,0] or List[2]== [0,0,0]:
    a = 'Yes'
for m in range(0,3):
    if List[0][m] == 0 and List[1][m] == 0 and List[2][m]==0:
        a ='Yes'
if List[0][0]==0 and List[1][1] == 0 and List[2][2]==0:
    a = 'Yes'
if List[0][2]==0 and List[1][1] == 0 and List[2][0]==0:
    a = 'Yes'
print (a)

Solution (Python):
a = []
b = [0] * 9

def match(n):
    if n in a:
        b[a.index(n)] += 1

def is_bingo(l, m, n):
    return b[l]*b[m]*b[n]

line = [[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):
    a += [int(i) for i in input().split()]
n = int(input())
for i in range(n):
    match(int(input()))
print('Yes' if any((is_bingo(line[i][0], line[i][1], line[i][2]) for i in range(8))) else 'No')

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

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

Bingo = [[False]*3 for _ in range(3)]
for k in range(9):
    i = k // 3
    j = k % 3
    for b in B:
        if A[i][j] == b:
            Bingo[i][j] = True

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

if Bingo[1][1] and Bingo[2][2] and Bingo[0][0] == True:
    print("Yes")
    exit()
if Bingo[0][2] and Bingo[1][1] and Bingo[2][0] == True:
    print("Yes")
    exit()

print("No")

Solution (Python):
table_1 = input().split()
table_2 = input().split()
table_3 = input().split()
bingo_card = table_1 + table_2 + table_3

N = int(input())

for _ in range(N):
    b = str(int(input()))
    if b in bingo_card:
        bingo_card[bingo_card.index(b)] = True
        
if bingo_card[0] == bingo_card[1] == bingo_card[2]:
    print('Yes')
elif bingo_card[3] == bingo_card[4] == bingo_card[5]:
    print('Yes')
elif bingo_card[6] == bingo_card[7] == bingo_card[8]:
    print('Yes')
elif bingo_card[0] == bingo_card[3] == bingo_card[6]:
    print('Yes')
elif bingo_card[1] == bingo_card[4] == bingo_card[7]:
    print('Yes')
elif bingo_card[2] == bingo_card[5] == bingo_card[8]:
    print('Yes')
elif bingo_card[0] == bingo_card[4] == bingo_card[8]:
    print('Yes')
elif bingo_card[2] == bingo_card[4] == bingo_card[6]:
    print('Yes')
else:
    print('No')