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):
B = []
for i in range(3):
    B += list(map(int,input().split()))

N = int(input())
Y = []
for i in range(N):
    b = int(input())
    if b in B:
        Y.append(B.index(b)+1)

if 1 in Y and 5 in Y and 9 in Y:
    print("Yes")
elif 3 in Y and 5 in Y and 7 in Y:
    print("Yes")
    
elif 1 in Y and 2 in Y and 3 in Y:
    print("Yes")
elif 4 in Y and 5 in Y and 6 in Y:
    print("Yes")
elif 7 in Y and 8 in Y and 9 in Y:
    print("Yes")
    
elif 1 in Y and 4 in Y and 7 in Y:
    print("Yes")
elif 2 in Y and 5 in Y and 8 in Y:
    print("Yes")
elif 3 in Y and 6 in Y and 9 in Y:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
import numpy as np
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
n = int(input())
t = np.zeros(8,dtype=int)
count = 0
for i in range(n):
    b = int(input())
    for j in range(3):
        if a1[j] == b:
            a1[j] = 0
        if a2[j] == b:
            a2[j] = 0
        if a3[j] == b:
            a3[j] = 0
if a1[0] + a2[0] + a3[0] == 0:
    count +=1
if a1[1] + a2[1] + a3[1] == 0:
    count +=1
if a1[2] + a2[2] + a3[2] == 0:
    count +=1
if a1[0] + a1[1] + a1[2] == 0:
    count +=1
if a2[0] + a2[1] + a2[2] == 0:
    count +=1
if a3[0] + a3[1] + a3[2] == 0:
    count +=1
if a1[0] + a2[1] + a3[2] == 0:
    count +=1
if a3[0] + a2[1] + a1[2] == 0:
    count +=1
if count == 0:
    print("No")
else:
    print("Yes")

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

p = []
p += a
p += [list(a_) for a_ in zip(*a)]
p += [[a[x][x] for x in range(3)]]
p += [[a[x][2-x] for x in range(3)]]

for p_ in p:
    for x in p_:
        if x in b:
            continue
        else:
            break
    else:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
row3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for n in range(N)]

col1 = [row1[0], row2[0], row3[0]]
col2 = [row1[1], row2[1], row3[1]]
col3 = [row1[2], row2[2], row3[2]]

diagonal1 = [row1[0], row2[1], row3[2]]
diagonal2 = [row1[2], row2[1], row3[0]]

all = row1 + row2 + row3

x = []
for i in b:
    if i in all:
        x.append(i)
    
if len(list(set(row1) & set(x))) == 3 or\
    len(list(set(row2) & set(x))) == 3 or\
    len(list(set(row3) & set(x))) == 3 or\
    len(list(set(col1) & set(x))) == 3 or\
    len(list(set(col2) & set(x))) == 3 or\
    len(list(set(col3) & set(x))) == 3 or\
    len(list(set(diagonal1) & set(x))) == 3 or\
    len(list(set(diagonal2) & set(x))) == 3:
    print('Yes')
else:
    print('No')

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

bingo = []

for i, a_li in enumerate(a_li_li):
    for j, a in enumerate(a_li):
        if a in b:
            bingo.append(i + j * 10)

if 0 in bingo and 10 in bingo and 20 in bingo:
    ans = 'Yes'
elif 1 in bingo and 11 in bingo and 21 in bingo:
    ans = 'Yes'
elif 2 in bingo and 12 in bingo and 22 in bingo:
    ans = 'Yes'
elif 0 in bingo and 1 in bingo and 2 in bingo:
    ans = 'Yes'
elif 10 in bingo and 11 in bingo and 12 in bingo:
    ans = 'Yes'
elif 20 in bingo and 21 in bingo and 22 in bingo:
    ans = 'Yes'
elif 0 in bingo and 11 in bingo and 22 in bingo:
    ans = 'Yes'
elif 2 in bingo and 11 in bingo and 20 in bingo:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Solution (Python):
a=[list(map(int,input().split()))for i in range(3)]
n=int(input())
b=[int(input())for i in range(n)]
ans='No'
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
      
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()))for _ in range(3)]
n=int(input())
b=[int(input())for _ in range(n)]
ans='No'
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
      
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):
bingo = [list(map(int, input().split())) for i in range(3)]
n = int(input())
for i in range(n):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == num:
                bingo[j][k] = 0
                break;
res = 'No'
for i in range(3):
    if bingo[i][0] == bingo[i][1] == bingo[i][2] == 0:
        res = 'Yes'
        break
    elif bingo[0][i] == bingo[1][i] == bingo[2][i] == 0:
        res = 'Yes'
        break
if bingo[0][2] == bingo[1][1] == bingo[2][0] == 0:
    res = 'Yes'
elif bingo[0][0] == bingo[1][1] == bingo[2][2] == 0:
    res = 'Yes'
print(res)

Solution (Python):
bingo = [list(map(int, input().split())) for i in range(3)]
n = int(input())
nums = [int(input()) for i in range(n)]
res = 'No'
for num in nums:
    for i in range(3):
        if num in bingo[i]:
            j = bingo[i].index(num)
            bingo[i][j] = 0
            if sum(bingo[i]) == 0 or sum([row[j] for row in bingo]) == 0:
                res = 'Yes'
            elif (i + j) % 2 == 0:
                if i + j == 2 and sum([bingo[0][2], bingo[1][1], bingo[2][0]]) == 0:
                    res = 'Yes'
                elif i == j and sum([bingo[0][0], bingo[1][1], bingo[2][2]]) == 0:
                    res = 'Yes'
            break
    if res == 'Yes':
        break
print(res)

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

p = []
p += a
p += [list(a_) for a_ in zip(*a)]
p += [[a[x][x] for x in range(3)]]
p += [[a[x][2-x] for x in range(3)]]

for p_ in p:
    for x in p_:
        if x in b:
            continue
        else:
            break
    else:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
A1 = [int(x) for x in input().split()]
A2 = [int(x) for x in input().split()]
A3 = [int(x) for x in input().split()]
n = int(input())
listA = [int(input()) for _ in range(n)]

list_bingo = [A1,A2,A3]

def check_bingo(list_bingo, N):
    for i in range(3):
        if list_bingo[i][0] == list_bingo[i][1] == list_bingo[i][2] == N or \
         list_bingo[0][i] == list_bingo[1][i] == list_bingo[2][i] == N:
            print('Yes')
            return
    if list_bingo[0][0] == list_bingo[1][1] == list_bingo[2][2] == N or \
    list_bingo[0][2] == list_bingo[1][1] == list_bingo[2][0] == N: 
        print('Yes')
        return
        
    print('No')
    return

listA = list(set(listA))
for i in range(len(listA)):
    for j in range(3):
        if listA[i] in list_bingo[j]:
            list_bingo[j][list_bingo[j].index(listA[i])] = 101
            
check_bingo(list_bingo, 101)

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

marked = []
for b in B:
    for i in range(3):
        if b not in A[i]:
            continue
        j = A[i].index(b)
        marked.append([i, j])

answer = 'No'
if (([0, 0] in marked and [1, 1] in marked and [2, 2] in marked) or
    ([0, 0] in marked and [0, 1] in marked and [0, 2] in marked) or
    ([1, 0] in marked and [1, 1] in marked and [1, 2] in marked) or
    ([2, 0] in marked and [2, 1] in marked and [2, 2] in marked) or
    ([0, 0] in marked and [1, 0] in marked and [2, 0] in marked) or
    ([0, 1] in marked and [1, 1] in marked and [2, 1] in marked) or
    ([0, 2] in marked and [1, 2] in marked and [2, 2] in marked) or
        ([2, 0] in marked and [1, 1] in marked and [0, 2] in marked)):
    answer = 'Yes'

print(answer)

Solution (Python):
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
S = []
for _ in range(N):
    S.append(int(input()))
mat = [0]*9
A = A1+A2+A3

for i in range(9):
  if A[i] in S:
    mat[i] = 1
res = 'No'
if sum(mat[0:9:3])==3 or sum(mat[1:9:3])==3 or sum(mat[2:9:3])==3 or sum(mat[0:3])==3 or sum(mat[3:6])==3 or sum(mat[6:9])==3 or sum(mat[0:9:4])==3 or sum(mat[2:7:2])==3:
  res = 'Yes'
print(res)

Solution (Python):
def z():
    print("Yes")
    exit()


a = []
for i in range(3):
    b, c, d = map(int, input().split())
    a.append([b, c, d])

n = int(input())

for i in range(n):
    t = int(input())
    for y in range(3):
        for x in range(3):
            if a[y][x] == t:
                a[y][x] = -1


for i in range(3):
    if sum(a[i]) == -3:
        z()

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

if a[0][0] + a[1][1] + a[2][2] == -3:
    z()

if a[0][2] + a[1][1] + a[2][0] == -3:
    z()
print("No")

Solution (Python):
NUM = 3
MAX_N = 100
def check(ty, yx, n):
    flg = False
    ty[yx[n]] += 1
    if NUM == ty[yx[n]]:
        flg = True
    return flg

def check_naname(nnm, y, x, n):
    flg = False
    if y[n] == x[n]:
        nnm[0] += 1
        if (NUM == nnm[0]):
            flg = True
    if y[n] == NUM - x[n] - 1:
        nnm[1] += 1
        if (NUM == nnm[1]):
            flg = True
    return flg

def main():
    y = [-1] * MAX_N
    x = [-1] * MAX_N
    for i in range(NUM):
        *A, = map(int, input().split())
        for j in range(NUM):
            A[j] -= 1
            y[A[j]] = i
            x[A[j]] = j
    N = int(input())
    tate = [0] * NUM
    yoko = [0] * NUM
    naname = [0] * 2
    flg = False
    for i in range(N):
        b = int(input())
        b -= 1
        if -1 == y[b]:
            continue
        flg = check(yoko, y, b)
        if flg:
            break
        flg = check(tate, x, b)
        if flg:
            break
        flg = check_naname(naname, y, x, b)
        if flg:
            break
    print("Yes" if flg else "No")
    return


main()

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

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

flag=False
for i in range(3):
    if (bingo[i][0]&bingo[i][1]&bingo[i][2])|(bingo[0][i]&bingo[1][i]&bingo[2][i]):
        flag=True

if (bingo[0][0]&bingo[1][1]&bingo[2][2])|(bingo[0][2]&bingo[1][1]&bingo[2][0]):
    flag=True

if flag:
    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)]

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

for i in range(N):
    for h in range(3):
        for w in range(3):
            if A[h][w] == B[i]:
                bingo[h][w] = 1


ans = "No"
for h in range(3):
    cnt = 0
    for w in range(3):
        if bingo[h][w]:
            cnt += 1
    if cnt == 3:
        ans = "Yes"

for w in range(3):
    cnt = 0
    for h in range(3):
        if bingo[h][w]:
            cnt += 1
    if cnt == 3:
        ans = "Yes"

cnt = 0
for a in range(3):
    if bingo[a][a]:
        cnt += 1
    if cnt == 3:
        ans = "Yes"
cnt = 0
for a, b in zip([0, 1, 2], [2, 1, 0]):
    if bingo[a][b]:
        cnt += 1
    if cnt == 3:
        ans = "Yes"
print(ans)

Solution (Python):
A1=[int(e) for e in input().split()]
A2=[int(f) for f in input().split()]
A3=[int(g) for g in input().split()]
N=int(input())
for i in range(N):
    b=int(input())
    for j in range(3):
        if b==A1[j]:
            A1[j]= -1
        elif b==A2[j]:
            A2[j]= -1
        elif b==A3[j]:
            A3[j]= -1
if A1[0]==-1 and A2[0]==-1 and A3[0]==-1:
    print('Yes')
elif A1[1]==-1 and A2[1]==-1 and A3[1]==-1:
    print('Yes')
elif A1[2]==-1 and A2[2]==-1 and A3[2]==-1:
    print('Yes')
elif A1[0]==-1 and A1[1]==-1 and A1[2]==-1:
    print('Yes')
elif A2[0]==-1 and A2[1]==-1 and A2[2]==-1:
    print('Yes')
elif A3[0]==-1 and A3[1]==-1 and A3[2]==-1:
    print('Yes')
elif A1[0]==-1 and A2[1]==-1 and A3[2]==-1:
    print('Yes')
elif A3[0]==-1 and A2[1]==-1 and A1[2]==-1:
    print('Yes')
else:
    print('No')

Solution (Python):
A1=[int(e) for e in input().split()]
A2=[int(f) for f in input().split()]
A3=[int(g) for g in input().split()]
N=int(input())
for i in range(N):
    b=int(input())
    for j in range(3):
        if b==A1[j]:
            A1[j]= -1
        elif b==A2[j]:
            A2[j]= -1
        elif b==A3[j]:
            A3[j]= -1
if A1[0]==-1 and A2[0]==-1 and A3[0]==-1:
    print('Yes')
elif A1[1]==-1 and A2[1]==-1 and A3[1]==-1:
    print('Yes')
elif A1[2]==-1 and A2[2]==-1 and A3[2]==-1:
    print('Yes')
elif A1[0]==-1 and A1[1]==-1 and A1[2]==-1:
    print('Yes')
elif A2[0]==-1 and A2[1]==-1 and A2[2]==-1:
    print('Yes')
elif A3[0]==-1 and A3[1]==-1 and A3[2]==-1:
    print('Yes')
elif A1[0]==-1 and A2[1]==-1 and A3[2]==-1:
    print('Yes')
elif A3[0]==-1 and A2[1]==-1 and A1[2]==-1:
    print('Yes')
else:
    print('No')

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

for x in range(3):
    for y in range(3):
        field[x][y] = 0

def is_bingo(f):
    fl_v = [0 for _ in range(3)]
    fl_h = [0 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if f[i][j] == 1:
                fl_v[j]+=1
    if max(fl_v)==3:
        return True
    for i in range(3):
        for j in range(3):
            if f[i][j] == 1:
                fl_h[i]+=1
    if max(fl_h)==3:
        return True

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

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

    return False

bingo_num = [(-1,-1) for _ in range(101)]

for x in range(3):
    ax = list(map(int,input().split()))
    for y in range(3):
        bingo_num[ax[y]] = (x,y)

n = int(input())

for x in range(n):
    bn = bingo_num[int(input())]
    field[bn[0]][bn[1]] = 1

if is_bingo(field):
    print('Yes')
else:
    print('No')

Solution (Python):
bingo=[input().split(' ') for _ in range(3)]


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


for i in range(3):
    for j in range(3):
        if bingo[i][j] in get:
            bingo[i][j] = 'A'



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

Solution (Python):
card = []
for i in range(3):
    a1,a2,a3 = map(int,input().split())
    card.append([a1,a2,a3])

n = int(input())

for i in range(n):
    num = int(input())
    for j in [0,1,2]:
        for k in [0,1,2]:
         if num == card[j][k]:
             card[j][k] = 0
if card[0] == [0,0,0] or card[1] == [0,0,0] or card[2] == [0,0,0]:
    print('Yes')
elif [card[i][0] for i in range(3)] == [0,0,0] or [card[i][1] for i in range(3)] == [0,0,0] or [card[i][2] for i in range(3)] == [0,0,0]:
    print('Yes')
elif [card[0][0],card[1][1],card[2][2]] == [0,0,0] or [card[0][2],card[1][1],card[2][0]] == [0,0,0]:
    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())

x = [[0,0,0],[0,0,0],[0,0,0]]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if A[j][k] == b[i]:
                x[j][k] = 1

ans = False

for i in range(3):
    if x[i] == [1,1,1]:
        ans = True
    
for i in range(3):
    if x[0][i] == 1 and x[1][i] == 1 and x[2][i] == 1:
        ans = True

if x[0][0] == 1 and x[1][1] == 1 and x[2][2] == 1:
    ans = True

if x[0][2] == 1 and x[1][1] == 1 and x[2][0] == 1:
    ans = True

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

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  
nl = lambda: list(map(int, stdin.readline().split()))

a = [na() for _ in range(3)]
x = [[-1] * 3 for _ in range(3)]
n = ni()
for i in range(n):
    b = ni()
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                x[j][k] = 1
flag = False
for i in range(3):
    if x[i][0] == x[i][1] and x[i][1] == x[i][2] and x[i][0] == 1 or x[0][i] == x[1][i] and x[1][i] == x[2][i] and x[0][i] == 1:
        flag = True
if x[0][0] == x[1][1] and x[1][1] == x[2][2] and x[0][0] == 1:
    flag = True
if x[0][2] == x[1][1] and x[1][1] == x[2][0] and x[0][2] == 1:
    flag = True
if flag:
    print('Yes')
else:
    print('No')

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

for i in range(int(input())):
  bn = int(input())
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == bn: bingo[j][k] = -1

if (bingo[0][0] == -1 and bingo[0][1] == -1 and bingo[0][2] == -1) or \
   (bingo[1][0] == -1 and bingo[1][1] == -1 and bingo[1][2] == -1) or \
   (bingo[2][0] == -1 and bingo[2][1] == -1 and bingo[2][2] == -1) or \
   (bingo[0][0] == -1 and bingo[1][0] == -1 and bingo[2][0] == -1) or \
   (bingo[0][1] == -1 and bingo[1][1] == -1 and bingo[2][1] == -1) or \
   (bingo[0][2] == -1 and bingo[1][2] == -1 and bingo[2][2] == -1) or \
   (bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1) or \
   (bingo[0][2] == -1 and bingo[1][1] == -1 and bingo[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()))

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


for j in range(3):
  for i in range(3):
    if A[i][j] in b:
      
      arr[i][j] = 1

f = 0
for i in range(3):
  if sum(arr[i][:]) == 3 and f == 0:
    print("Yes")
    f = 1

  if (arr[0][i] + arr[1][i] + arr[2][i] == 3) and f == 0:
    print("Yes")
    f = 1
    
if f == 0:
  if arr[0][0] + arr[1][1] + arr[2][2] == 3:
    print("Yes")
  elif arr[0][2] + arr[1][1] + arr[2][0] == 3:
    print("Yes")
  else:
    print("No")

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

n=int(input())
for i in range(n):
  b=int(input())
  try:
    A[A.index(b)]=0
  except:
    continue

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

Solution (Python):
matrix = []
for i in range(3):
    matrix.append(list(map(int, input().split())))
col = [[0, 0, 0] for i in range(3)]
for _ in range(int(input())):
    n = int(input())
    for i in range(3):
        for j in range(3):
            if matrix[i][j] == n:
                col[i][j] = 1
                break
f = 0
sd1 = col[0][2] + col[1][1] + col[2][0]
if sd1 == 3:
    print('Yes')
    exit()
sd = 0
for i in range(3):
    s, s1 = 0, 0
    sd += col[i][i]
    for j in range(3):
        s += col[i][j]
        s1 += col[j][i]
    if s == 3 or s1 == 3:
        f = 1
        break
if f:
    print('Yes')
else:
    if sd == 3:
        print('Yes')
    else:
        print('No')

Solution (Python):
x1   = list(map(int, input().split()))
x2   = list(map(int, input().split()))
x3   = list(map(int, input().split()))
card = [x1, x2, x3]

numLen  = int(input())
numList = [int(input()) for _ in range(numLen)]
ans = "No"
for x in range(3):
    for y in range(3):
        for numList_i in range(numLen):
            if card[x][y] == numList[numList_i]:
                card[x][y] = "x"

for i in range(3):
    if card[i][0] == "x" and card[i][1] == "x" and card[i][2] == "x":
        ans = "Yes"
    if card[0][i] == "x" and card[1][i] == "x" and card[2][i] == "x":
        ans = "Yes"

if card[0][0] == "x" and card[1][1] == "x" and card[2][2] == "x":
    ans = "Yes"
if card[0][2] == "x" and card[1][1] == "x" and card[2][0] == "x":
    ans = "Yes"
print(ans)

Solution (Python):
import sys
b = [0] * 3
c = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

b[0] = list(input().split())
b[1] = list(input().split())
b[2] = list(input().split())




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


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

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

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

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

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

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

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

print('No')

Solution (Python):
A = [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 = False

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

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

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

cnt_2 = 0
for i in range(3):
    cnt_2 += A[i][2-i]
if cnt_2 == 0:
    ans = True

print("Yes") if ans 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
judge = False

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

for i in range(3):
    tmp = []
    for j in range(3):
        tmp.append(A[j][i])
    if tmp[1:] == tmp[:-1]:
        judge = True

tmp_2 = []
for i in range(3):
    tmp_2.append(A[i][i])
if tmp_2[1:] == tmp_2[:-1]:
    judge = True
tmp_3 = []
for i in range(3):
    tmp_3.append(A[i][2-i])
if tmp_3[1:] == tmp_3[:-1]:
    judge = True
print("Yes") if judge else print("No")

Solution (Python):

def judgehol(a, b):
    for i in range(3):
        flag = [False, False, False]
        for j in range(3):
            if a[i][j] in b:
                flag[j] = True
        if flag[0] and flag[1] and flag[2]:
            break
    return flag[0] and flag[1] and flag[2]


def judgever(a, b):
    for j in range(3):
        flag = [False, False, False]
        for i in range(3):
            if a[i][j] in b:
                flag[i] = True
        if flag[0] and flag[1] and flag[2]:
            break
    return flag[0] and flag[1] and flag[2]



def judgecross(a, b):
    if a[0][0] in b and a[1][1] in b and a[2][2] in b:
        return True
    elif a[0][2] in b and a[1][1] in b and a[2][0] in b:
        return True
    else:
        return False


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

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


if judgehol(a, b) or judgever(a, b) or judgecross(a, b):
    print('Yes')
else:
    print('No')

Solution (Python):
bingo = [[int(i) for i in input().split()] for _ in range(3)]
n = int(input())

l = [int(input()) for _ in range(n)]
ans = [[0 for _ in range(3)] for _ in range(3)]

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


flg = False
for i in range(3):
    if sum(ans[i]) == 3:
        flg = True
        break
    elif ans[0][i] + ans[1][i] + ans[2][i] == 3:
        flg = True
        break
    else:
        pass
    
if ans[0][0] + ans[1][1] + ans[2][2] == 3 or ans[0][2] + ans[1][1] + ans[2][0] == 3:
    flg = True
    
print('Yes' if flg else 'No')

Solution (Python):
m = []
for _ in range(3):
	m.append(list(map(int, input().split())))
n = int(input())
nums = set()
for _ in range(n):
	nums.add(int(input()))

flag = True

for r in m:
	count = 0
	for elem in r:
		if elem in nums:
			count += 1
	if (count == len(r)):
		flag = False
		break

if flag:
	for r in zip(*m):
		count = 0
		for elem in r:
			if elem in nums:
				count += 1
		if (count == len(r)):
			flag = False
			break
if flag:
	count = 0
	for i in range(3):
		if m[i][i] in nums:
			count += 1
	if (count == 3):
		flag = False
if flag:
	if len({m[0][2],m[1][1],m[2][0]} & nums)==3:
		flag=False
if flag:
	print("No")
else:
	print("Yes")

Solution (Python):
bingo = []
flag = [0, 0, 0, 0, 0, 0, 0, 0, 0]
bingo.extend(input('').split(' '))
bingo.extend(input('').split(' '))
bingo.extend(input('').split(' '))
N = int(input(''))

for i in range(N):
    b = input('')
    if b in bingo:
        flag[bingo.index(b)] = 1

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

Solution (Python):
import sys

ar = []
x = sys.stdin.readline()
x = x.split(' ')
ar.extend([int(str) for str in x])
x = sys.stdin.readline()
x = x.split(' ')
ar.extend([int(str) for str in x])
x = sys.stdin.readline()
x = x.split(' ')
ar.extend([int(str) for str in x])

n = int(sys.stdin.readline())
ret = []
for i in range(n):
  b = int(sys.stdin.readline())
  if( b in ar):
    index = ar.index(b)
    ret.append(index)

result = "No"
for i in range(0,3):
  if( i*3+0 in ret and i*3+1 in ret and i*3+2 in ret ):
    result = "Yes"
  if( i+0*3 in ret and i+1*3 in ret and i+2*3 in ret ):
    result = "Yes"
if( 0 in ret and 4 in ret and 8 in ret ):
  result = "Yes"
if( 2 in ret and 4 in ret and 6 in ret ):
  result = "Yes"

print(result)



sys.stdout.flush()

Solution (Python):



A=[raw_input().split() for i in range(3)]
b=[]
N=int(raw_input())
for i in range(N):
    b.append(raw_input())

C=[[0 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]):
               C[j][k]=1


kekka='No'

for i in range(3):
    m=0
    for j in range(3):
        m=m+C[i][j]
    if(m==3):
       kekka='Yes'
       break
            
for i in range(3):
    m=0
    for j in range(3):
        m=m+C[j][i]
    if(m==3):
       kekka='Yes'
       break

m=0
for i in range(3):
    m=m+C[i][i]
    if(m==3):
       kekka='Yes'
       break

m=0
for i in range(3):
    m=m+C[i][2-i]
    if(m==3):
       kekka='Yes'
       break

print kekka

Solution (Python):
def ball(card, number, state):
    for a in range(3):
        for b in range(3):
            if(card[a][b] == number):
                state[a][b] = 1

def check(state):
    for m in range(3):
        if(min(state[m]) == 1):
            return True
    for m in range(3):
        if(state[0][m] == 1 and state[1][m] == 1 and state[2][m] == 1):
            return True
    if(state[0][0] == 1 and state[1][1] == 1 and state[2][2] == 1):
        return True
    if(state[2][0] == 1 and state[1][1] == 1 and state[2][0] == 1):
        return True
    return False

                
state = [[0 for i in range(3)] for j in range(3)]
card = [list(map(int, input().split())) for i in range(3)]
N = int(input())
for n in range(N):
    ball(card, int(input()), state)
if(check(state)):
    print("Yes")
else:
    print("No")