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.



Sample input:
84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30


Sample output:
Yes

Submission status: Accepted

Solution code:
a = []
b = []
for _ in range(3):
  a.append(list(map(int,input().split())))
n = int(input())
for _ in range(n):
  b.append(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
        
flg = 0
if flg == 0:
  for i in range(3):
    if flg ==0:
      for j in range(3):
        if a[i][j] == 0 and j != 2:
          continue
        elif j == 2 and a[i][j]==0:
          flg = 1
        else:
          break
if flg == 0:
  for i in range(3):
    if flg ==0:
      for j in range(3):
        if a[j][i] == 0 and j != 2:
          continue
        elif j == 2 and a[j][i]==0:
          flg = 1
        else:
          break
if flg == 0:
  for i in range(3):
    if a[i][i] == 0 and i != 2:
      continue
    elif a[i][i] == 0:
      flg = 1
    else:
      break
if flg == 0:
  for i in range(3):
    if a[i][2-i] == 0 and i != 2:
      continue
    elif a[i][2-i] == 0:
      flg = 1
    else:
      break
if flg == 0:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
p,r=input,range
A=sum([list(map(int,p().split()))for _ in r(3)],[])
b=[int(p())for _ in r(int(p()))]
print('YNeos'[all([sum(1<<i for i in r(9)if A[i]in b)&v!=v for v in[7,56,73,84,146,273,292,448]])::2])

Submission status: Accepted

Solution code:
p,r=input,range
A=sum([list(map(int,p().split()))for _ in r(3)],[])
b=[int(p())for _ in r(int(p()))]
print('Yes'if[v for v in[7,56,73,84,146,273,292,448]if sum(1<<i for i in r(9)if A[i]in b)&v==v]else'No')

Submission status: Accepted

Solution code:
p,r=input,range
A=sum([list(map(int,p().split()))for _ in r(3)],[])
N=int(p())
b=[int(p())for _ in r(N)]
print('Yes'if[v for v in[7,56,73,84,146,273,292,448]if sum(1<<i for i in r(9)if A[i]in b)&v==v]else'No')

Submission status: Accepted

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

f=sum(1<<i for i in range(9)if A[i]in b)
print('Yes'if[v for v in[7,56,73,84,146,273,292,448]if f&v==v]else'No')

Submission status: Accepted

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

f=0
for i in range(9):
	if A[i]in b:f|=1<<i
ans=[v for v in [7,56,73,84,146,273,292,448]if f&v==v]
print('Yes' if ans else 'No')

Submission status: Accepted

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

f=0
for v in b:
	for i in range(9):
		if A[i // 3][i % 3] == v:
			f|=1<<i
ans=[v for v in [7,56,73,84,146,273,292,448]if f&v==v]
print('Yes' if ans else 'No')

Submission status: Accepted

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

f=0
for v in b:
	for i in range(9):
		if A[i // 3][i % 3] == v:
			f|=1<<i
ans = 0
for v in [7,56,73,84,146,273,292,448]:
  ans |= f&v==v;
print('Yes' if ans else 'No')

Submission status: Accepted

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

field = 0
for v in b:
	for i in range(9):
		if A[i // 3][i % 3] == v:
			field = field | (1 << i)
ans = False
for v in sum([[273,84],sum([[73<<i,7<<i*3]for i in range(3)],[])],[]):
  ans = ans or field&v==v;
print('Yes' if ans else 'No')

Submission status: Accepted

Solution code:
a=[]
for _ in range(3): a.append(list(map(int,input().split())))
n=int(input())
for _ in range(n):
    b=int(input())
    for i in range(3):
        for j,val in enumerate(a[i]):
            if val==b: a[i][j]=0

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

Submission status: Accepted

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

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

if A[0][0] == A[1][0] == A[2][0]:
    print("Yes")
elif A[0][0] == A[0][1] == A[0][2]:
    print("Yes")
elif A[0][1] == A[1][1] == A[2][1]:
    print("Yes")
elif A[0][2] == A[1][2] == A[2][2]:
    print("Yes")
elif A[1][0] == A[1][1] == A[1][2]:
    print("Yes")
elif A[2][0] == A[2][1] == A[2][2]:
    print("Yes")
elif A[0][0] == A[1][1] == A[2][2]:
    print("Yes")
elif A[0][2] == A[1][1] == A[2][0]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
for k in range(n):
  for i in range(3):
    for j in range(3):
      if a[i][j]==b[k]:
        a[i][j]=-1
def result():
  for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==-1 or a[0][i]==a[1][i]==a[2][i]==-1:
      return 'Yes'
  if a[0][0]==a[1][1]==a[2][2]==-1 or a[0][2]==a[1][1]==a[2][0]==-1:
    return 'Yes'
  else:
    return 'No'
print(result())

Submission status: Accepted

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

for i in range(n):
  d=int(input())
  for j in range(9):
    if l1[j]==d:
      l1[j]=0
if l1[0]+l1[1]+l1[2]==0 or l1[3]+l1[4]+l1[5]==0 or l1[6]+l1[7]+l1[8]==0 or l1[0]+l1[4]+l1[8]==0 or l1[2]+l1[4]+l1[6]==0 or l1[0]+l1[3]+l1[6]==0 or l1[1]+l1[4]+l1[7]==0 or l1[2]+l1[5]+l1[8]==0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    A = []
    for i in range(3):
        A.append([int(x) for x in input().split()])
    N = int(input())
    bingo = [[False] * 3 for _ in range(3)]
    for n in range(N):
        B = int(input())
        for i in range(3):
            if B in A[i]:
                bingo[i][A[i].index(B)] = True
    for i in range(3):
        if bingo[i][0] == bingo[i][1] == bingo[i][2] is True:
            print('Yes')
            return
        if bingo[0][i] == bingo[1][i] == bingo[2][i] is True:
            print('Yes')
            return
    if bingo[0][0] == bingo[1][1] == bingo[2][2] is True:
        print('Yes')
        return
    if bingo[0][2] == bingo[1][1] == bingo[2][0] is True:
        print('Yes')
        return
    print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A = []
hit = []
for _ in range(3):
    A.append(list(map(int, input().split())))
    hit.append([False]*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:
                hit[i][j] = True
                break

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

print('No')

Submission status: Accepted

Solution code:
a = []
b = []
ans = 'No'

for i in range(3):
    a.extend([int(s) for s in input().split()])
n = int(input())
for j in range(n):
    value = int(input())
    b.append(value)
    if value in a:
        a[a.index(value)] = '*'

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[4] == a[8]:
    ans = 'Yes'
if a[0] == a[3] == a[6] or a[1] == a[4] == a[7] or a[2] == a[5] == a[8] or a[2] == a[4] == a[6]:
    ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
b = []
for i in range(3):
  lst = list(map(int,input().split()))
  b.append(lst)
n = int(input())
for i in range(n):
  a = int(input())
  for j in range(3):
    for k in range(3):
      if (b[j][k] == a):
        b[j][k] = 0
if (b[0][0] == b[0][1] == b[0][2] or b[1][0] == b[1][1] == b[1][2] or b[2][0] == b[2][1] == b[2][2] or b[0][0] == b[1][0] == b[2][0] or b[0][1] == b[1][1] == b[2][1] or b[0][2] == b[1][2] == b[2][2] or b[0][0] == b[1][1] == b[2][2] or b[0][2] == b[1][1] == b[2][0]):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def row():
  c=0
  for y in range(HEIGHT):
    for x in range(WIDTH):
      if A[y][x]!=-1:
        break
    else:
      c+=1
  return c


def col():
  c=0
  for x in range(WIDTH):
    for y in range(HEIGHT):
      if A[y][x]!=-1:
        break
    else:
      c+=1
  return c


def obl():
  c=0
  for z in range(HEIGHT):
    if A[z][z]!=-1:
      break
  else:
    c+=1
  
  y=0
  for x in range(WIDTH-1,-1,-1):
    if A[y][x]!=-1:
      break
    y+=1
  else:
    c+=1
  return c  
    

def main():
  for b in B:
    for y in range(HEIGHT):
      for x in range(WIDTH):
        if A[y][x]==b:
          A[y][x]=-1
  cnt=row()+col()+obl()
  print('Yes' if cnt else 'No')

  
if __name__=='__main__':
  HEIGHT=3
  WIDTH=3
  A=[[int(a) for a in input().split()] for y in range(HEIGHT)]
  N=int(input())
  B=[int(input()) for n in range(N)]
  main()

Submission status: Accepted

Solution code:
board = []

def detect():
    if sum([board[0], board[4], board[8]]) == 0:
        return True

    if sum([board[2], board[4], board[6]]) == 0:
        return True

    for i in range(3):
        if sum([board[i], board[i + 3], board[i + 6]]) == 0:
            return True

    for i in range(0, 3 * 3, 3):
        if sum([board[i], board[i + 1], board[i + 2]]) == 0:
            return True

    return False


for i in range(3):
    row = [int(v) for v in input().rstrip().split()]
    board.extend(row)


N = int(input().rstrip())
for i in range(N):
    b = int(input().rstrip())
    try:
        j =  board.index(b)
        board[j] = 0
    except ValueError:
        pass

r = 'Yes' if detect() else 'No'
print(r)

Submission status: Accepted

Solution code:
a = []
a1 = []
for i in range(3):
    a2 = list(map(int, input().split()))
    a.append(a2)
    a1 += a2
n = int(input())
b = []
num = 0
for h in range(n):
    b1 = int(input())
    if b1 in a1:
        num += 1
    b.append(b1)
if num < 3:
    print('No')
else:
    z = 'No'
    for j in range(3):
        if a[j][0] in b and a[j][1] in b and a[j][2] in b:
            z = 'Yes'
            break
        if a[0][j] in b and a[1][j] in b and a[2][j] in b:
            z = 'Yes'
            break
    if z == 'No':
        if a[0][0] in b and a[1][1] in b and a[2][2] in b:
            z = 'Yes'
        elif a[2][0] in b and a[1][1] in b and a[0][2] in b:
            z = 'Yes'
    print(z)

Submission status: Accepted

Solution code:
Aij= [input().split() for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b[n]:
                Aij[j][k]='0'
if Aij[0].count('0')==3 or Aij[1].count('0')==3 or Aij[2].count('0')==3:
    print('Yes')
elif Aij[0][0]=='0' and Aij[1][0]=='0' and Aij[2][0]=='0':
    print('Yes')
elif Aij[0][1]=='0' and Aij[1][1]=='0' and Aij[2][1]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][2]=='0' and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][0]=='0'and Aij[1][1]=='0'and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][1]=='0'and Aij[2][0]=='0':
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for k in range(N):
    B = int(input())
    for l in range(3):
        for m in range(3):
            if A[l][m] == B:
                A[l][m] = 0

if (A[0][0] == A[0][1] == A[0][2] == 0) or (A[1][0] == A[1][1] == A[1][2] == 0) or (A[2][0] == A[2][1] == A[2][2] == 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")
elif (A[0][0] == A[1][1] == A[2][2] == 0) or (A[0][2] == A[1][1] == A[2][0] == 0):
    print ("Yes")
else:
    print ("No")

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline

A = [list(map(int, readline().split())) for _ in range(3)]

G = [[0, 0, 0] for _ in range(3)]
N = int(readline())
B = [int(readline()) for _ in range(N)]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                G[i][j] = 1

ans = 'No'

if G[0][0] and G[1][1] and G[2][2]:
    ans = 'Yes'
if G[0][2] and G[1][1] and G[2][0]:
    ans = 'Yes'

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

print(ans)

Submission status: Accepted

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

bingocard = [[0]*4 for _ in range(4)]
N = int(input())
for _ in range(N):
    b = int(input())
    for row in range(3):
        for col in range(3):
            if b == A[row][col]:
                bingocard[row][col] = 1
                bingocard[row][3] += 1
                bingocard[3][col] += 1

flag = False
#横
for row in bingocard:
    if row[3] == 3:
        flag = True

#縦
for col in bingocard[3]:
    if col == 3:
        flag = True
    
#斜め
if bingocard[0][0] + bingocard[1][1] + bingocard[2][2] == 3:
    flag = True
if bingocard[2][0] + bingocard[1][1] + bingocard[0][2] == 3:
    flag = True

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

Submission status: Accepted

Solution code:
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                a[i][j] = -1
f = False
for i in range(3):
    for j in range(3):
        if (a[0][0] == a[0][1] == a[0][2]== -1) or (a[1][0] == a[1][1] == a[1][2]== -1) or (a[2][0] == a[2][1] == a[2][2]== -1):
            f = True
        elif (a[0][0] == a[1][0] == a[2][0] == -1) or (a[0][1] == a[1][1] == a[2][1] == -1) or (a[0][2] == a[1][2] == a[2][2] == -1):
            f = True
        elif (a[0][0] == a[1][1] == a[2][2] == -1) or (a[2][0] == a[1][1] == a[0][2] == -1):
            f = True
if f:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A = [0]*3
A[0] = list(map(int, input().split()))
A[1] = list(map(int, input().split()))
A[2] = list(map(int, input().split()))
n = int(input())
b = [0]*n
for i in range(n):
  b[i] = int(input())

flag = []
flag.append([0]*3)
flag.append([0]*3)
flag.append([0]*3)


for i in range(3):
  for j in range(3):
    if A[i][j] in b:
      flag[i][j] = 1
#print(flag)      
  
ans = "No"
for i in range(3):
  if flag[i] == [1,1,1]:
    ans = "Yes"
  
x = [0,0,0]
y = [0, 0]
for i in range(3):
  y[0] += flag[i][i]
  y[1] += flag[i][2-i]
  for j in range(3):
  	x[j] += flag[i][j]
#print(x,y)
if 3 in x:
  ans = "Yes"
if 3 in y:
  ans = "Yes"
  
print(ans)

Submission status: Accepted

Solution code:
a_1 = list(map(int,input().split()))
a_2 = list(map(int,input().split()))
a_3 = list(map(int,input().split()))
a = [a_1,a_2,a_3]
n = int(input())
for i in range(n):
  h = int(input())
  for j in range(3):
    for k in range(3):
      if(a[j][k]==h):
        a[j][k]=0
ans = "No"
for i in range(3):
  if(a[i][0]==0)and(a[i][0]==a[i][1])and(a[i][1]==a[i][2]):
    ans = "Yes"
for i in range(3):
  if(a[0][i]==0)and(a[0][i]==a[1][i])and(a[1][i]==a[2][i]):
    ans= "Yes"
if((a[0][0]==0)and(a[1][1]==a[2][2])and(a[0][0]==a[1][1]))or((a[0][2]==0)and(a[1][1]==a[2][0])and(a[0][2]==a[1][1])):
  ans = "Yes"
  
print(ans)

Submission status: Accepted

Solution code:
a1, a2, a3 = map(int,input().split())
a4, a5, a6 = map(int, input().split())
a7, a8, a9 = map(int, input().split())
lis = [a1, a2, a3, a4, a5, a6, a7, a8, a9]
n = int(input())

for _ in range(n):
  b = int(input())
  for i in range(9):
    if b == lis[i]:
      lis[i] = 0

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

Submission status: Accepted

Solution code:
l=list(map(int,input().split()))
l+=list(map(int,input().split()))
l+=list(map(int,input().split()))

n=int(input())

ans_list=[False]*9

for i in range(n):
  num=int(input())
  if num in l:
    index=l.index(num)
    ans_list[index]=True
    
if ans_list[0] and ans_list[1] and ans_list[2]:
  print("Yes")
elif ans_list[0] and ans_list[3] and ans_list[6]:
  print("Yes")
elif ans_list[3] and ans_list[4] and ans_list[5]:
  print("Yes")
elif ans_list[6] and ans_list[7] and ans_list[8]:
  print("Yes")
elif ans_list[1] and ans_list[4] and ans_list[7]:
  print("Yes")
elif ans_list[2] and ans_list[5] and ans_list[8]:
  print("Yes")
elif ans_list[0] and ans_list[4] and ans_list[8]:
  print("Yes")
elif ans_list[2] and ans_list[4] and ans_list[6]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
card = []
check = [False for i in range(9)]
for i in range(3):
  card += list(map(int, input().split()))
N = int(input())
for i in range(N):
  a = int(input())
  if a in card:
    check[card.index(a)] = True
ans = "No"
for i in range(3):
  if check[i] and check[3+i] and check[6+i]:
    ans = "Yes"
  if check[i*3] and check[i*3+1] and check[i*3+2]:
    ans = "Yes"
if check[4] and ((check[0] and check[8])or(check[2] and check[6])):
  ans = "Yes"
  
print(ans)

Submission status: Accepted

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

N=int(input())

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

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

import numpy as np

if min(np.sum(x, axis=0))==0:
	kotae='Yes'
elif min(np.sum(x, axis=1))==0:
	kotae='Yes'
elif x[0][0]==0 and x[1][1]==0 and x[2][2]==0:
	kotae='Yes'
elif x[2][0]==0 and x[1][1]==0 and x[0][2]==0:
	kotae='Yes'
else:
	kotae='No'

print(kotae)

Submission status: Accepted

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


def ball(b):
    global A
    for c in range(3):
        for co in range(3):
            if A[c][co] == b:
                A[c][co] = "ok"


for c in range(N):
    b = int(input())
    ball(b)


if A[0].count("ok") == 3 or A[1].count("ok") == 3 or A[2].count("ok") == 3:
    print("Yes")
elif A[0][0] == "ok" and A[1][0] == "ok" and A[2][0] == "ok":
    print("Yes")
elif A[0][1] == "ok" and A[1][1] == "ok" and A[2][1] == "ok":
    print("Yes")
elif A[0][2] == "ok" and A[1][2] == "ok" and A[2][2] == "ok":
    print("Yes")
elif A[0][0] == "ok" and A[1][1] == "ok" and A[2][2] == "ok":
    print("Yes")
elif A[0][2] == "ok" and A[1][1] == "ok" and A[2][0] == "ok":
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A = [[int(i) for i in input().split()] for _ in range(3)]
N = int(input())
for i in range(N) :
    b = int(input())
    for j in range(3) :
        if b in A[j] :
            x = A[j].index(b)
            A[j][x] = 0
        
#print(A)

for i in range(3) :
    if all(A[i][n] == 0 for n in range(3)) or all(A[m][i] == 0 for m in range(3)):
        print('Yes')
        exit()
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0 :
    print('Yes')
    exit()
if A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0 :
    print('Yes')
    exit()
print('No')

Submission status: Accepted

Solution code:
a = [input().split() for l in range(3)]
n = int(input())
b = list(input() for i in range(n))
c = [[0] * 3 for i in range(3)]

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

if (c[0][0] == 1 and c[0][1] == 1 and c[0][2] == 1) or(c[1][0] == 1 and c[1][1] == 1 and c[1][2] == 1) or(c[2][0] == 1 and c[2][1] == 1 and c[2][2] == 1) or(c[0][0] == 1 and c[1][0] == 1 and c[2][0] == 1) or(c[0][1] == 1 and c[1][1] == 1 and c[2][1] == 1) or(c[0][2] == 1 and c[1][2] == 1 and c[2][2] == 1) or(c[0][0] == 1 and c[1][1] == 1 and c[2][2] == 1) or (c[0][2] == 1 and c[1][1] == 1 and c[2][0] == 1):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
L = []
p = "No"
for i in range(3):
  a, b, c = map(str, input().split())
  L.append(a)
  L.append(b)
  L.append(c)
n = int(input())
for i in range(n):
  d = input()
  for j in range(9):
    if d == L[j]:
      L[j] = "×"
if (L[0] == "×" and L[8] == "×" and L[4] == "×") or (L[1] == "×" and L[7] == "×" and L[4] == "×") or (L[2] == "×" and L[6] == "×" and L[4] == "×") or (L[3] == "×" and L[5] == "×" and L[4] == "×"):
  p = "Yes"
elif (L[0] == "×" and L[1] == "×" and L[2] == "×") or (L[2] == "×" and L[5] == "×" and L[8] == "×") or (L[0] == "×" and L[3] == "×" and L[6] == "×") or (L[6] == "×" and L[7] == "×" and L[8] == "×"):
  p="Yes"
print(p)

Submission status: Accepted

Solution code:
a = [list(map(int, input().split())) for _ in range(3) ]
n = int(input())
b = [int(input()) for i in range(n)]
for j in range(n):
    for k in range(3):
        for l in range(3):
            if b[j] == a[k][l]:
                a[k][l] = "o"
if a[0][0] == "o" and a[0][1] == "o" and a[0][2] == "o":
    print("Yes")
elif a[1][0] == "o" and a[1][1] == "o" and a[1][2] == "o":
    print("Yes")
elif a[2][0] == "o" and a[2][1] == "o" and a[2][2] == "o":
    print("Yes")
elif a[0][0] == "o" and a[1][0] == "o" and a[2][0] == "o":
    print("Yes")
elif a[0][1] == "o" and a[1][1] == "o" and a[2][1] == "o":
    print("Yes")
elif a[0][2] == "o" and a[1][2] == "o" and a[2][2] == "o":
    print("Yes")
elif a[0][0] == "o" and a[1][1] == "o" and a[2][2] == "o":
    print("Yes")
elif a[0][2] == "o" and a[1][1] == "o" and a[2][0] == "o":
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))
l += list(map(int, input().split()))
l += list(map(int, input().split()))
n = int(input())
for i in range(n):
  b = int(input())
  if b in l:
    index = l.index(b)
    l[index] = 0
if l[0] == l[1] == l[2] or l[3] == l[4] == l[5] or l[6] == l[7] == l[8] or l[0] == l[3] == l[6] or l[1] == l[4] == l[7] or l[2] == l[5] == l[8] or l[0] == l[4] == l[8] or l[2] == l[4] == l[6]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
X = 3
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))
def checkbingo(a):
    for i,j,k in bingo:
        if a[i] + a[j] + a[k] == 0:
            return True 
    return False
    
    

a = []
for i in range(X):
    a += list(map(int,input().split()))
    
N = int(input())
for j in range(N):
    b = int(input())
    if b in a:
        a[a.index(b)] = 0
if checkbingo(a):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
arr = []
temp = []
for i in range(3):
    t = list(map(int, input().split()))
    arr.append(t)
    temp.extend(t)
    
n = int(input())
for i in range(n):
    a = int(input())
    if a in temp:
        for i in range(3):
            for j in range(3):
                if arr[i][j] == a:
                    arr[i][j] = 'X'
                if arr[0][j] == arr[1][j] == arr[2][j] or  arr[0][0] == arr[1][1] == arr[2][2] or arr[0][2] == arr[1][1] == arr[2][0] or set(arr[i]) == {'X'}:
                    print('Yes')
                    exit()
        
print('No')

Submission status: Accepted

Solution code:
A=[]
for _ in range(3):
    A+=map(int,input().split())

N=int(input())
for _ in range(N):
    b=int(input())
    if b in A:
        A[A.index(b)]=0

for i,j,k in [
    (0,1,2),(3,4,5),(6,7,8),
    (0,3,6),(1,4,7),(2,5,8),
    (0,4,8),(2,4,6),
]:
    if A[i]==A[j]==A[k]:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

Solution code:
A=[]
for _ in range(3):
    A+=map(int,input().split())

N=int(input())
for _ in range(N):
    b=int(input())
    if b in A:
        A[A.index(b)]=0

p=[
  (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,j,k in p:
    if A[i]==A[j]==A[k]:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

Solution code:
A=[]
for _ in range(3):
    A+=map(int,input().split())

N=int(input())
for _ in range(N):
    b=int(input())
    if b in A:
        A[A.index(b)]=0

p=[
  (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,j,k in p:
    if A[i]==A[j]==A[k]==0:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

Solution code:
def bingo():
    for i in a:
        if i[0] in b and i[1] in b and i[2] in b:
            return True
    for i in range(3):
        if a[0][i] in b and a[1][i] in b and a[2][i] in b:
            return True
    tmp=[(a[i][i] in b) for i in range(3)]
    if tmp.count(True)==3:
        return True
    tmp=[a[0][2] in b,a[1][1] in b,a[2][0] in b]
    if tmp.count(True)==3:
        return True
 
a=[[int(i)for i in input().split()]for j in range(3)]
n=int(input())
b=[int(input())for i in range(n)]
bingo=bingo()
print("Yes" if bingo else "No")

Submission status: Accepted

Solution code:
def bingo():
    for i in a:
        tmp=0
        for j in i:
            if j in b:
                tmp+=1
        if tmp==3:
            return True
    for i in range(3):
        tmp=0
        for j in a:
            if j[i] in b:
                tmp+=1
        if tmp==3:
            return True
    tmp=[(a[i][i] in b) for i in range(3)]
    if tmp.count(True)==3:
        return True
    tmp=[a[0][2] in b,a[1][1] in b,a[2][0] in b]
    if tmp.count(True)==3:
        return True

a=[[int(i)for i in input().split()]for j in range(3)]
n=int(input())
b=[int(input())for i in range(n)]
bingo=bingo()
print("Yes" if bingo else "No")

Submission status: Accepted

Solution code:
A = []
is_checked = []
res = False

for i in range(3):
    A.append(list(map(int, input().split())))

N = int(input())

b = {int(input()) for i in range(N)}

for i in range(3):
    is_checked.append([False]*3)
    for j in range(3):
        if A[i][j] in b:
            is_checked[i][j] = True

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

if is_checked[0][0] and is_checked[1][1] and is_checked[2][2]:
    res = True
if is_checked[0][2] and is_checked[1][1] and is_checked[2][0]:
    res = True

print(['No', 'Yes'][res])

Submission status: Accepted

Solution code:
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

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

N = int(input())
for n in range(N):
  b = int(input())
  if my_index(A1, b) is not False:
    A1[my_index(A1, b)] = -1
  if my_index(A2, b) is not False:
    A2[my_index(A2, b)] = -1
  if my_index(A3, b) is not False:
    A3[my_index(A3, b)] = -1

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

Submission status: Accepted

Solution code:
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for x in range(3):
        for y in range(3):
            if a[x][y] == b:
                a[x][y] = 'o'
for x in range(3):
    if a[x][0] == a[x][1] == a[x][2] == 'o':
        print('Yes')
        exit(0)
for y in range(3):
    if a[0][y] == a[1][y] == a[2][y] == 'o':
        print('Yes')
        exit(0)
if a[0][0] == a[1][1] == a[2][2] == 'o':
    print('Yes')
elif a[0][2] == a[1][1] == a[2][0] == 'o':
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

n = int(input())
ans = False

for i in range(n):
    b = int(input())
    for  j in range(3):
        if b in card[j]:
            card[j][card[j].index(b)] = 0

def judge(lst):
    return lst == [0,0,0]

for i in range(3):
    ans |= judge(card[i])
for i in range(3):
    ans |= judge([card[j][i] for j in range(3)])
ans |= judge([card[i][i] for i in range(3)])
ans |= judge([card[i][2-i] for i in range(3)])

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

Submission status: Accepted

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

G=[['.']*3 for _ in range(3)]
for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            G[i][j]='#'
# print(G)

if any(all(G[i][j]=='#' for i in range(3)) for j in range(3)) or \
   any(all(G[i][j]=='#' for j in range(3)) for i in range(3)) or \
   all(G[i][2-i]=='#' for i in range(3)) or \
   all(G[i][i]=='#' for i in range(3)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
listA = []
listB = []
for _ in range(3):
    listA.append(list(map(int, input().split())))
N = int(input())
for _ in range(N):
    listB.append(int(input()))
tate =  [0 , 0 , 0]
yoko = [0, 0, 0]
naname = [0, 0] 
for i in range(3):
    for j in range(3):
        if listA[i][j] in listB:
            tate[i] += 1
            yoko[j] += 1
            if i == j:
                naname[0] += 1
            if  i + j == 2:
                naname[1] += 1
if  3 in tate or 3 in yoko or 3 in naname:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a=[]
for _ in range(3):
  b=list(map(int,input().split()))
  a.append(b)
  
n=int(input())
for _ in range(n):
  x=int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j]==x:
        a[i][j]=-1
        
if a[0][0]==a[0][1]==a[0][2] or a[1][0]==a[1][1]==a[1][2] or a[2][0]==a[2][1]==a[2][2] or a[0][0]==a[1][0]==a[2][0]  or a[0][1]==a[1][1]==a[2][1] or a[0][2]==a[1][2]==a[2][2] or a[0][0]==a[1][1]==a[2][2] or a[0][2]==a[1][1]==a[2][0]:
  print('Yes')
else:
  print('No')