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: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

a = inl()
b = inl()
c = inl()
n = ini()
bingo = []
for _ in range(n):
    bingo.append(ini())
ct = [0] * 9
for i in bingo:
    if i in a:
        ct[a.index(i)] = 1
    if i in b:
        ct[b.index(i) + 3] = 1
    if i in c:
        ct[c.index(i) + 6] = 1
if sum(ct[:3]) == 3 or sum(ct[3:6] or sum(ct[6:9]) == 3):
    print("Yes")
elif ct[0] + ct[4] + ct[8] == 3 or ct[2] + ct[4] + ct[6] == 3:
    print("Yes")
elif ct[0] + ct[3] + ct[6] == 3 or ct[1] + ct[4] + ct[7] == 3 or ct[2] + ct[5] + ct[8] == 3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

a = inl()
b = inl()
c = inl()
n = ini()
bingo = []
for _ in range(n):
    bingo.append(ini())
ct = [0] * 9
for i in bingo:
    if i in a:
        ct[a.index(i)] = 1
    if i in b:
        ct[b.index(i) + 3] = 1
    if i in c:
        ct[c.index(i) + 6] = 1
if sum(ct[:3]) == 3 or sum(ct[3:6] or sum(ct[6:9]) == 3):
    print("Yes")
elif ct[0] + ct[4] + ct[8] == 3 or ct[2] + ct[4] + ct[6]:
    print("Yes")
elif ct[0] + ct[3] + ct[6] == 3 or ct[1] + ct[4] + ct[7] == 3 or ct[2] + ct[5] + ct[8] == 3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

a = inl()
b = inl()
c = inl()
n = ini()
bingo = []
for _ in range(n):
    bingo.append(ini())
ct = [0] * 9
for i in bingo:
    if i in a:
        ct[a.index(i)] = 1
    if i in b:
        ct[b.index(i) + 3] = 1
    if i in c:
        ct[c.index(i) + 6] = 1
if sum(ct[:3]) == 3 or sum(ct[3:6] or sum(ct[6:9]) == 3):
    print("Yes")
elif ct[0] + ct[4] + ct[8] == 3 or ct[2] + ct[4] + ct[6]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

a = inl()
b = inl()
c = inl()
n = ini()
bingo = []
for _ in range(n):
    bingo.append(ini())
ct = [0] * 9
for i in bingo:
    if i in a:
        ct[a.index(i)] = 1
    if i in b:
        ct[b.index(i) + 3] = 1
    if i in c:
        ct[c.index(i) + 6] = 1
if sum(ct[:3]) == 3 or sum(ct[3:6] or sum(ct[6:9]) == 3):
    print("YES")
elif ct[0] + ct[4] + ct[8] == 3 or ct[2] + ct[4] + ct[6]:
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

b =[]
n = int(input())
c =[[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):
            if a[j][k] == b[i]:
                c[j][k] += 1

cnt = 0
if c[0][0]+c[1][1]+c[2][2]==3 or c[0][2]+c[1][1]+c[2][0]==3:
    print('Yes')
else:
    for i in range(3):
        if sum(c[i])==3:
            print('Yes')
            break

        for j in range(3):
            if c[i][j]==1:
                cnt += 1
        if cnt==3:
            print('Yes')
            break
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
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()))



flag = 0
cnt = 0
# yoko
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            cnt += 1
    else:
        if cnt == 3:
            print("Yes")
            flag += 1
            exit()
        else:
            cnt = 0

# tate
if flag == 0:
    for i in range(3):
        for j in range(3):
            if a[j][i] in b:
                cnt += 1

        else:
            if cnt == 3:
                print("Yes")
                flag += 1
                exit()
            else:
                cnt = 0


# ななめ
if flag ==0:
    for i in range(3):
        if a[i][i] in b:
             cnt += 1
    else:
        if cnt == 3:
            print("Yes")
            flag += 1
            exit()
        else:
            cnt = 0

if flag == 0:
    print("No")

Submission status: Wrong Answer

Solution code:
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()))

print(b)

flag = 0
cnt = 0
# yoko
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            cnt += 1
    else:
        if cnt == 3:
            print("Yes")
            flag += 1
            exit()
        else:
            cnt = 0

# tate
if flag == 0:
    for i in range(3):
        for j in range(3):
            if a[j][i] in b:
                cnt += 1

        else:
            if cnt == 3:
                print("Yes")
                flag += 1
                exit()
            else:
                cnt = 0


# ななめ
if flag ==0:
    for i in range(3):
        if a[i][i] in b:
             cnt += 1
    else:
        if cnt == 3:
            print("Yes")
            flag += 1
            exit()
        else:
            cnt = 0

if flag == 0:
    print("No")

Submission status: Wrong Answer

Solution code:
A1 = [int(_) for _ in input().split()]
A2 = [int(_) for _ in input().split()]
A3 = [int(_) for _ in input().split()]
A_list = [A1, A2, A3]
N = int(input())
b_list = []
for _ in range(N):
    b_list.append(int(input()))

bingo_card = [[False, False, False], [False, False, False], [False, False, False]]

for b in b_list:
    for i in range(3):
        for j in range(3):
            if A_list[i][j] == b:
                bingo_card[i][j] = True

flg = False
for i in range(3):
    if bingo_card[i] == [True, True, True]:
        flg = True
        break
for i in range(3):
    if bingo_card[:][i] == [[True], [True], [True]]:
        flg = True
        break
if [bingo_card[0][0], bingo_card[2][2], bingo_card[1][1]] == [True, True, True]:
    flg = True
if [bingo_card[0][2], bingo_card[2][0], bingo_card[1][1]] == [True, True, True]:
    flg = True

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

Submission status: Wrong Answer

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

bingo = 'No'

for t in zip(*a):
    a.append(list(t))

a.append([a[i][i] for i in range(3)])
a.append([a[i][2-i]for i in range(3)])

for line in a:
    if all(item in b for item in a):
        bingo = 'Yes'

print(bingo)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
    nums = np.array(read().split(), np.int64)
    a = nums[:9]

    for x in nums[10:]:
        a[a == x] = 0
    pos = ((0,1,2), (3,4,5), (6,7,8), (0,3,6), (1,4,7), (2,5,7), (0,4,8), (2,4,6))
    for pose in pos:
        if a[pose[0]] == a[pose[1]] == a[pose[2]] == 0:
            print('Yes')
            sys.exit()
    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
bingo = []
for i in range(3):
  bingo.append(list(map(int, input().split())))
bingo = sum(bingo, [])
N = int(input())
for _ in range(N):
  b = int(input())
  if b in bingo:
    bingo[bingo.index(b)] = True
if (bingo[0] and bingo[1] and bingo[2]) or (bingo[3] and bingo[4] and bingo[5]) or \
   (bingo[6] and bingo[7] and bingo[8]) or (bingo[0] and bingo[3] and bingo[6]) or \
   (bingo[1] and bingo[4] and bingo[7]) or (bingo[2] and bingo[5] and bingo[8]) or \
   (bingo[0] and bingo[4] and bingo[8]) or (bingo[2] and bingo[4] and bingo[6]):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
A_Bingo = []
for i in range(3):
    A_Bingo.append(list(map(int,input().split())))

card =[]
n = int(input())
for k in range(n):
    card.append(int(input()))

r_cnt =[0,0,0]
c_cnt =[0,0,0]
rc_result = [[0,0,0],[0,0,0],[0,0,0]]

for row in range(3):
    for column in range(3):
        if A_Bingo[row][column] in card:
            r_cnt[row] += 1
            c_cnt[column] += 1
            rc_result[row][column] = 1

if 2 in r_cnt:
    print("Yes")
elif 2 in c_cnt:
    print("Yes")
elif rc_result[0][0]*rc_result[1][1]*rc_result[2][2] == 1:
    print("Yes")
elif rc_result[0][2]*rc_result[1][1]*rc_result[2][0] == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s = "012 345 678 036 147 258 048 246"
a = [input().split() for i in range(3)]
b = a[0] + a[1] + a[2]

for i in [input()for i in range(int(input()))]:
  if i in b:
    s = s.replace(str(b.index(i)), "")
print("Yes" if "  " in s else "No")

Submission status: Wrong Answer

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

c = [[a[0][0], a[1][1], a[2][2]], [a[0][2], a[1][1], a[2][0]]]

print("Yes" if any(i.count(0) == 3 for i in a) or any(i.count(0) == 3 or any(i.count(0) == 3 for i in c) for i in zip(*a)) else "No")

Submission status: Wrong Answer

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
print("Yes" if any(i.count(0) == 3 for i in a) or any(i.count(0) == 3 for i in zip(*a)) else "No")

Submission status: Wrong Answer

Solution code:
bingo=[]
for i in range(3):
  a=list(map(int,input().split()))
  bingo.append(a)
  
n=int(input())
for i in range(n):
  b=int(input())
  for j in range(3):
    if b in bingo[j]:
      bingo[j][bingo[j].index(b)]=0
      
def hantei(l):
  for i in range(3):
    if all([l[i][j]==0 for j in range(3)]):
      return 'Yes'
    
    elif all([l[j][i]==0 for j in range(3)]):
      return 'Yes'
    
    elif l[0][0]==0 and l[1][1]==0 and l[2][2]==0:
      return 'Yes'
    
    elif l[0][2]==0 and l[1][1]==0 and l[2][0]==0:
      return 'Yes'
    
    else:
      return 'No'
    
print(hantei(bingo))

Submission status: Wrong Answer

Solution code:
ri = lambda S: [int(v) for v in S.split()]

S = [ri(input()) for _ in range(3)]
N = int(input())
D = set()

def mark(A, v):
    for i in range(3):
        for j in range(3):
            if A[i][j] != 0 and A[i][j] == v:
                A[i][j] = 0
                if (i, j) in [(0, 0), (1, 1), (2,2)]:
                    D.add((i,j))

for _ in range(N):
    b = int(input())
    mark(S, b)

R = [sum(r) for r in S]
C = [sum(r) for r in zip(*S)]

check = len(D) == 3 or any(v == 0 for v in R) or any(v == 0 for v in C)

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

Submission status: Wrong Answer

Solution code:
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
num=0
for s in range(3):
    num1=0
    for t in range(3):
        if A[s][t] in B:
            num1+=1
    if num1==3:
        num+=1
num2=0
for u in range(3):
    if A[u][u] in B:
        num2+=1
if num2==3:
    num+=1
num3=0
for v in range(3):
    if A[2-v][v] in B:
        num3+=1
if num3==3:
    num+=1
if num>0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
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()))
  
flugs = [[False] * 3 for i in range(3)]
for i in range(3):
  for j in range(3):
    if A[i][j] in b:
      flugs[i][j] = True
      
result = 'No'
for i in range(3):
  if all(flugs[i][:]) or all(flugs[:][i]):
    result = 'Yes'
  
if all([flugs[0][0], flugs[1][1], flugs[2][2]]):
  result = 'Yes'
    
elif all([flugs[2][0], flugs[1][1], flugs[0][2]]):
  result = 'Yes'
    
print(result)

Submission status: Wrong Answer

Solution code:
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()))
  
flugs = [[False] * 3 for i in range(3)]
for i in range(3):
  for j in range(3):
    if A[i][j] in b:
      flugs[i][j] = True
      
result = 'No'
for i in range(3):
  if all(flugs[i]) or all(flugs[:][i]):
    result = 'Yes'
  
if all([flugs[0][0], flugs[1][1], flugs[2][2]]):
  result = 'Yes'
    
elif all([flugs[2][0], flugs[1][1], flugs[0][2]]):
  result = 'Yes'
    
print(result)

Submission status: Wrong Answer

Solution code:
A = []
A.append(input().split())
A.append(input().split())
A.append(input().split())
N = int(input())
b = [input() for _ in range(N)]
 
# 2次元配列として処理
for i in range(N):
  for j in range(3):
    if b[i] in A[j]: A[j][A[j].index(b[i])] = True

if (A[0][0] and A[1][0] and A[2][0]) or (A[0][1] and A[1][1] and A[2][1]) or (A[0][2] and A[1][2] and A[2][2]) or (A[0][0] and A[0][1] and A[0][2]) or (A[1][0] and A[1][1] and A[1][2]) or (A[2][0] and A[2][1] and A[2][2]) or (A[0][0] and A[1][1] and A[2][2]) or (A[0][2] and A[1][1] and A[2][0]): print('Yes')
else: print('No')

Submission status: Wrong Answer

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

# 2次元配列として処理
for i in range(N):
  for j in range(3):
    if b[i] in A[j]: A[j][A[j].index(b[i])] = True

if (A[0][0] and A[1][0] and A[2][0]) or (A[0][1] and A[1][1] and A[2][1]) or (A[0][2] and A[1][2] and A[2][2]) or (A[0][0] and A[0][1] and A[0][2]) or (A[1][0] and A[1][1] and A[1][2]) or (A[2][0] and A[2][1] and A[2][2]) or (A[0][0] and A[1][1] and A[2][2]) or (A[0][2] and A[1][1] and A[2][0]): print('Yes')
else: print('No')

Submission status: Wrong Answer

Solution code:
A = []
A.append(input().split())
A.append(input().split())
A.append(input().split())
N = int(input())
b = [input() for _ in range(N)]
 
for i in range(N):
  for j in range(3):
    if b[i] in A[j]: A[j][A[j].index(b[i])] = True
    
if (A[0][0] and A[1][0] and A[2][0]) or (A[0][1] and A[1][1] and A[2][1]) or (A[0][2] and A[1][2] and A[2][2]) or (A[0[0]] and A[0][1] and A[0][2]) or (A[1][0] and A[1][1] and A[1][2]) or (A[2][0] and A[2][1] and A[2][2]) or (A[0][0] and A[1][1] and A[2][2]) or (A[0][2] and A[1][1] and A[2][0]): print('Yes')
else: print('No')

Submission status: Wrong Answer

Solution code:
l=[]
for i in range(3):
    l.append(list(map(int,input().split())))
d=list(zip(*l))
s=[]
f=0
n=int(input())
for i in range(n):
    s.append(int(input()))
for i in range(3):
    c=0
    for j in range(3):
        if(l[i][j] in s):
            c+=1
    if(c==3):
        f=1
        break
if(l[1][1] in s and l[0][0] in s and l[2][2] in s):
    f=1
for i in range(3):
    c=0
    for j in range(3):
        if(d[i][j] in s):
            c+=1
    if(c==3):
        f=1
        break
if(f==1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
matrix = []
for i in range(3):
    line = []
    line = input().split(" ")
    matrix.append(line)

n = int(input())
chosen = 0

for i in range(n):
    b = input()
    for i in range(3):
        for j in range(3):
            if matrix[i][j] == b:
                chosen += 1
                matrix[i][j] = 0
bingo = False
if (chosen >= 3):
    for i in range(3):
        if(matrix[i][0] == 0 and matrix[i][1] == 0 and matrix[i][2] == 0):
            bingo = True
            break
        elif(matrix[0][i] == 0 and matrix[1][i] == 0 and matrix[2][i] == 0):
            bingo = True
            break
    if(matrix[1][1] == 0 and (matrix[0][0] == 0 and matrix[2][2] == 0) or (matrix[0][2] == 0 and matrix[2][0] == 0)):
        bingo = True

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

Submission status: Wrong Answer

Solution code:
matrix = []
for i in range(3):
    line = []
    line = input().split(" ")
    matrix.append(line)

n = int(input())
chosen = 0

for i in range(n):
    b = input()
    for i in range(3):
        for j in range(3):
            if matrix[i][j] == b:
                chosen += 1
                matrix[i][j] = 0
bingo = False
# Squares conditions
if (chosen == 8):
    for i in range(3):
        for j in range (3):
            if not (i == 1 and j == 1):
                if(matrix[i][j] != 0):
                    break
                if(i == 2 and j == 2):
                    bingo = True
elif (chosen >= 3):
    for i in range(3):
        if(matrix[i][0] == 0 and matrix[i][1] == 0 and matrix[i][2] == 0):
            bingo = True
            break
        elif(matrix[0][i] == 0 and matrix[1][i] == 0 and matrix[2][i] == 0):
            bingo = True
            break
    if(matrix[1][1] and (matrix[0][0] == 0 and matrix[2][2] == 0) or (matrix[0][2] == 0 and matrix[2][0] == 0)):
        bingo = True

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

Submission status: Wrong Answer

Solution code:
matrix = []
for i in range(3):
    line = []
    line = input().split(" ")
    matrix.append(line)

n = int(input())
chosen = 0

for i in range(n):
    b = input()
    for i in range(3):
        for j in range(3):
            if matrix[i][j] == b:
                chosen += 1
                matrix[i][j] = 0
bingo = False
if chosen == 9:
    bingo = True
# Squares conditions
elif (chosen == 8):
    for i in range(3):
        for j in range (3):
            if(i != 1 and j != 1):
                if(matrix[i][j] != 0):
                    break
                if(i == 2 and j == 2):
                    bingo = True
elif (chosen >= 3):
    for i in range(3):
        if(matrix[i][0] == 0 and matrix[i][1] == 0 and matrix[i][2] == 0):
            bingo = True
            break
        elif(matrix[0][i] == 0 and matrix[1][i] == 0 and matrix[2][i] == 0):
            bingo = True
            break
    if(matrix[1][1] and (matrix[0][0] == 0 and matrix[2][2] == 0) or (matrix[0][2] == 0 and matrix[2][0] == 0)):
        bingo = True

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

Submission status: Wrong Answer

Solution code:
matrix = []
for i in range(3):
    line = []
    line = input().split(" ")
    matrix.append(line)

n = int(input())
chosen = 0

for i in range(n):
    b = input()
    for i in range(3):
        for j in range(3):
            if matrix[i][j] == b:
                chosen += 1
                matrix[i][j] = 0
bingo = False
if chosen == 9:
    bingo = True
# Squares conditions
elif (chosen == 8):
    for i in range(3):
        for j in range (3):
            if(i != 1 and j != 1):
                if(matrix[i][j] != 0):
                    break
                if(i == 2 and j == 2):
                    bingo = True
elif (chosen >= 3 and matrix[1][1] == 0):
    if((matrix[0][0] == 0 and matrix[2][2] == 0) or (matrix[0][2] == 0 and matrix[2][0] == 0)):
        bingo = True

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

Submission status: Wrong Answer

Solution code:
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r3 = list(map(int, input().split()))

a = [r1, r2, r3]

n = int(input())

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


for i in r1:

	x= 0
	if i in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()

for i in r2:
	x= 0
	if i in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()

for i in r3:
	x= 0
	if i in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()	



if a[0][0] in b and a[1][0] in b and a[2][0] in b:
	print('Yes')
	quit()
if a[0][1] in b and a[1][1] in b and a[2][1] in b:
	print('Yes')
	quit()
if a[0][2] in b and a[1][2] in b and a[2][2] in b:
	print('Yes')
	quit()
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
	print('Yes')
	quit()
if a[0][2] in b and a[1][1] in b and a[2][0] in b:
	print('Yes')
	quit()
print('No')

Submission status: Wrong Answer

Solution code:
def main():
  array = []
  for number in range(3):
    new = []
    kek = input()
    split = kek.split()
    for item in split:
      new.append([int(item), False])
    array.append(new)

  number = int(input())
  
  for item in range(number):
    single = int(input())
    for row in array:
      for column in row:
        if column[0] == single:
          column[1] = True

  if (array[0][0][1] and array[0][1][1] and array[0][2][1] or
      array[1][0][1] and array[1][1][1] and array[1][2][1] or
      array[2][0][1] and array[1][1][1] and array[2][2][1] or 
      array[0][0][1] and array[1][0][1] and array[2][0][1] or
      array[0][1][1] and array[1][1][1] and array[2][1][1] or
      array[0][2][1] and array[1][2][1] and array[2][2][1] or
      array[0][0][1] and array[1][1][1] and array[2][2][1] or
      array[0][2][1] and array[1][1][1] and array[2][0][1]
    ):
    answer = 'Yes'
  else:
    answer = 'No'

  print(answer)





if __name__ == "__main__":
  # execute only if run as a script
  main()

Submission status: Wrong Answer

Solution code:
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r3 = list(map(int, input().split()))

a = [r1, r2, r3]

n = int(input())

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


for i in r1:

	x= 0
	if i in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()

for i in r2:
	x= 0
	if i in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()

for i in r3:
	x= 0
	if i in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()	



for i in range(3):
	x= 0
	if a[i][0] in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()	

for i in range(3):
	x= 0
	if a[i][1] in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()	

for i in range(3):
	x= 0
	if a[i][2] in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()

if a[0][0] in b and a[1][1] in b and a[2][2] in b:
	print('Yes')
	quit()

if a[0][2] in b and a[1][1] in b and a[2][0] in b:	
	print('Yes')
	quit()

print('No')

Submission status: Wrong Answer

Solution code:
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r3 = list(map(int, input().split()))

a = [r1, r2, r3]

n = int(input())

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


for i in r1:

	x= 0
	if i in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()

for i in r2:
	x= 0
	if i in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()

for i in r3:
	x= 0
	if i in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()	



for i in range(3):
	x= 0
	if a[i][0] in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()	

for i in range(3):
	x= 0
	if a[i][1] in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()	

for i in range(3):
	x= 0
	if a[i][2] in b:
		x+= 1
	if x == 3:
		print('Yes')
		quit()

if a[0][0] in b and a[1][1] in b and a[2][2]:
	print('Yes')
	quit()

if a[0][2] in b and a[1][1] in b and a[2][0]:	
	print('Yes')
	quit()

print('No')

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
  A.append(list(map(int, input().split())))
B = [[0]*3]*3
N = int(input())
for i in range(N):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k] == b:
        B[j][k] = 1
c = []
for i in range(3):
  c.append(B[i][0] | B[i][1] | B[i][2])
  c.append(B[0][i] | B[1][i] | B[2][i])
c.append(B[0][0] | B[1][1] | B[2][2])
c.append(B[0][2] | B[1][1] | B[2][0])
if sum(c) > 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
  A.append(list(map(int, input().split())))
print(A)
B = [[0]*3]*3
N = int(input())
for i in range(N):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k] == b:
        B[j][k] = 1
c = []
for i in range(3):
  c.append(B[i][0] | B[i][1] | B[i][2])
  c.append(B[0][i] | B[1][i] | B[2][i])
c.append(B[0][0] | B[1][1] | B[2][2])
c.append(B[0][2] | B[1][1] | B[2][0])
if sum(c) > 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
  A.append(list(map(int, input().split())))
B = [[0 for i in range(3)] for j in range(3)]
N = int(input())
for i in range(N):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k] == b:
        B[j][k] == 1
c = []
for i in range(3):
  c.append(B[i][0] | B[i][1] | B[i][2])
  c.append(B[0][i] | B[1][i] | B[2][i])
c.append(B[0][0] | B[1][1] | B[2][2])
c.append(B[0][2] | B[1][1] | B[2][0])
if sum(c) > 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
x = []

for i in range(3):
  a =input().split()
  x.append(a)

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

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

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

Submission status: Wrong Answer

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

Bingo = [[0, 0, 0] for _ in range(3)] 
for i in range(3):
  for j in range(3):
    for l in range(N):
      if(A[i][j] == b[l]):
        Bingo[i][j] = 1
bingo = 0
for i in range(3):
  if(Bingo[i][0]+Bingo[i][1]+Bingo[i][2])==3:
    bingo += 1
  elif(Bingo[0][i]+Bingo[1][i]+Bingo[2][i])==3:
    bingo += 1
if(Bingo[0][0]+Bingo[1][1]+Bingo[2][2]):
  bingo += 1
elif(Bingo[0][2]+Bingo[1][1]+Bingo[2][0]):
  bingo += 1

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

Submission status: Wrong Answer

Solution code:
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()))

card = [[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]:
                card[j][k] = True

if card[0][0]:
    if card[0][1] and card[0][2]:
        print('Yes')
    elif card[1][0] and card[2][0]:
        print('Yes')
    elif card[1][1] and card[2][2]:
        print('Yes')
elif card[0][1] and card[1][1] and card[2][1]:
    print('Yes')
elif card[0][2]:
    if card[1][2] and card[2][2]:
        print('Yes')
    elif card[1][1] and card[2][0]:
        print('Yes')
elif card[1][0] and card[1][1] and card[1][2]:
    print('Yes')
elif card[2][0] and card[2][1] and card[2][2]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
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()))

card = [[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]:
                card[j][k] = 1

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

Submission status: Wrong Answer

Solution code:
list1 = []

for i in range(3):
  a =input().split()
  list1.append(a)
x = [x for d in list1 for x in d]


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

for y in b:
  if y in x:
    index = x.index(y)
    x.remove(y)
    x.insert(index, '*')
if x[:3].count('*') == 3 or x[3:6] == 3 or x[6:9] == 3:
  print('Yes')
elif x[0] == x[3] == x[6] == '*' or x[1] == x[4] == x[7] == '*' or x[2] == x[5] == x[8]:
  print('Yes')
elif x[0] == x[4] == x[8] == '*' or x[2] == x[4] == x[6] == '*':
  print ('Yes')
else:
  print('No')

Submission status: Wrong Answer

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'[any([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: Wrong Answer

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
print('Yes'if sum(f&v==v for v in[7,23,56,84,146,273,292,448])else'No')

Submission status: Wrong Answer

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 sum(f&v==v for v in[7,23,56,84,146,273,292,448])else'No')

Submission status: Wrong Answer

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 i in range(3):
	ans = ans or (field & (7 << (i * 3))) or (field & (73 << i))
ans = ans or (field & 273) or (field & 84)
print('Yes' if ans else 'No')

Submission status: Wrong Answer

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 i in range(3):
	ans = ans or field & (7 << (i * 3)) or (field & (73 << i))
ans = ans or (field & 273) or (field & 84)
print('Yes' if ans else 'No')

Submission status: Wrong Answer

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 i in range(3):
	ans = ans or field & (7 << (i * 3)) or (field & 73 << i)
ans = ans or (field & 273) or (field & 84)
print('Yes' if ans else 'No')