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
card = [[int(x) for x in input().split(' ') ] for _ in range(3)]

patterns = []

patterns += [[card[i][j] for i in range(3)] for j in range(3)]
patterns += [[card[j][i] for i in range(3)] for j in range(3)]
patterns.append([card[i][i] for i in range(3)])
patterns.append([card[2-i][2-i] for i in range(3)] )

ok = False
N = int(input())
for _ in range(N):
    b = int(input())
    for pat in patterns:
        if b in pat:
            pat.remove(b)
        
        if len(pat)==0:
            ok = True

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

Submission status: Wrong Answer

Solution code:
import sys
card = [[int(x) for x in input().split(' ') ] for _ in range(3)]

patterns = []

patterns += [[card[i][j] for i in range(3)] for j in range(3)]
patterns += [[card[j][i] for i in range(3)] for j in range(3)]
patterns.append([card[i][i] for i in range(3)])
patterns.append([card[2-i][2-i] for i in range(3)] )

ok = False
N = int(input())
for _ in range(N):
    b = int(input())
    for pat in patterns:
        if b in pat:
            pat.remove(b)
        
        if len(pat)==0:
            ok = True

if ok:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
import sys
card = [[int(x) for x in input().split(' ') ] for _ in range(3)]

patterns = []

patterns += [[card[i][j] for i in range(3)] for j in range(3)]
patterns += [[card[j][i] for i in range(3)] for j in range(3)]
patterns.append([card[i][i] for i in range(3)])
patterns.append([card[2-i][2-i] for i in range(3)] )

N = int(input())
for _ in range(N):
    b = int(input())
    for pat in patterns:
        if b in pat:
            pat.remove(b)
        
        if len(pat)==0:
            print('YES')
            sys.exit()

print('NO')

Submission status: Wrong Answer

Solution code:
mat=[list(map(int,input().split())) for i in range(3)]
print(mat)
N=int(input())
c=0
for n in range(N):
  b=int(input())
  for i in range(3):
    for j in range(3):
      if mat[i][j]==b:
        mat[i][j]=0
for i in range(3):
  if mat[i][0]==0 and mat[i][1]==0 and mat[i][2]==0:
    c+=1
  elif mat[0][i]==0 and mat[1][i]==0 and mat[2][i]==0:
    c+=1
  elif mat[0][0]==0 and mat[1][1]==0 and mat[2][2]==0:
    c+=1
  elif mat[0][2]==0 and mat[1][1]==0 and mat[2][0]==0:
    c+=1

if c >= 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
mat=[list(map(int,input().split())) for i in range(3)]
print(mat)
N=int(input())
c=0
for n in range(N):
  b=int(input())
  for i in range(3):
    for j in range(3):
      if mat[i][j]==b:
        mat[i][j]=0
for i in range(3):
  if mat[i][0]==0 and mat[i][1]==0 and mat[i][2]==0:
    c+=1
  elif mat[0][i]==0 and mat[1][i]==0 and mat[2][i]==0:
    c+=1
  elif mat[0][0]==0 and mat[1][1]==0 and mat[2][2]==0:
    c+=1
  elif mat[0][2]==0 and mat[1][1]==0 and mat[2][0]==0:
    c+=1

if c >= 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
A1 = input().split()
A2 = input().split()
A3 = input().split()

hit_example = [7,56,73,84,146,273,292,448]
b = 0
ans = "no"

N = int(input())
for i in range(N):
  x = int(input())
  if int(A1[0]) == x:
    b += 256
  elif int(A1[1]) == x:
    b += 128
  elif int(A1[2]) == x:
    b += 64
  elif int(A2[0]) == x:
    b += 32
  elif int(A2[1]) == x:
    b += 16
  elif int(A2[2]) == x:
    b += 8
  elif int(A3[0]) == x:
    b += 4
  elif int(A3[1]) == x:
    b += 2
  elif int(A3[2]) == x:
    b += 1

for val in hit_example:
  if val & b == val:
    ans = "yes"
    break
    
print(ans)

Submission status: Wrong Answer

Solution code:
A1 = [int(x) for x in input().rstrip().split()]
A2 = [int(x) for x in input().rstrip().split()]
A3 = [int(x) for x in input().rstrip().split()]

for i in A2:
    A1.append(i)

for l in A3:
    A1.append(l)

N = int(input())

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

for i in range(N):
    a=int(input())
    if my_index(A1,a)!=-1:
        A1[my_index(A1,a)]=0

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

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
  a = input().split()
  a = [int(num) for num in a]
  A.append(a)

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

for i in range(3):
  for j in range(3):
    if b.count(A[i][j]) != 0:
      A[i][j] = 0
    else:
      continue

def Agetraw(j):
    Ans = [int(A[i][j]) for i in range(3)]
    return(Ans)

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

Submission status: Wrong Answer

Solution code:
l1=[int(x) for x in input().rstrip().split()]
l2=[int(x) for x in input().rstrip().split()]
l3=[int(x) for x in input().rstrip().split()]
l=[]

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

for i in l1:
    l.append(i)
for i in l2:
    l.append(i)
for i in l3:
    l.append(i)

n=int(input())
for i in range(n):
    b=int(input())
    a = my_index(l,b)
    if my_index(l,b)!=-1:
        l[a]=0

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

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
  a = input().split()
  a = [int(num) for num in a]
  A.append(a)

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

for i in range(3):
  for j in range(3):
    if b.count(A[i][j]) != 0:
      A[i][j] = 0
    else:
      continue

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

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
  a = input().split()
  a = [int(num) for num in a]
  A.append(a)

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

for i in range(3):
  for j in range(3):
    if b.count(A[i][j]) != 0:
      A[i][j] = 0
    else:
      continue

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

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
  a = input().split()
  a = [int(num) for num in a]
  A.append(a)

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

for i in range(3):
  for j in range(3):
    if b.count(A[i][j]) != 0:
      A[i][j] = 0
    else:
      continue

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

Submission status: Wrong Answer

Solution code:
A = []
for i in range(3):
  a = input().split()
  a = [int(num) for num in a]
  A.append(a)

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

for i in range(3):
  for j in range(3):
    if b.count(A[i][j]) != 0:
      A[i][j] = 0
    else:
      continue

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

Submission status: Wrong Answer

Solution code:
def main():
  a = []
  ans = "No"
  hit_examples = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
  for i in range(3):
    a.extend(list(map(int, input().split())))
  n = int(input())
  b = []
  for i in range(n):
    b.append(int(input()))
  for b_value in b:
    for i in range(len(a)):
      if b_value == a[i]:
        a[i] = -1

  for hit_example in hit_examples:
    cnt = 0
    for i in range(len(a)):
      if a[i] == -1 and i in hit_example:
        cnt += 1
      if cnt == 3:
        ans = "Yes"
        print(ans)
        return
  print(ans)

Submission status: Wrong Answer

Solution code:
def main():
  a = []
  ans = "No"
  hit_examples = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
  for i in range(3):
    a.extend(list(map(int, input().split())))
  n = int(input())
  b = []
  for i in range(n):
    b.append(int(input()))
  for b_value in b:
    for i in range(len(a)):
      if b_value == a[i]:
        a[i] = -1

  for hit_example in hit_examples:
    cnt = 0
    for i in range(len(a)):
      if a[i] == -1 and i in hit_example:
        cnt += 1
      if cnt <= 3:
        ans = "Yes"
        print(ans)
        return
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  a = []
  ans = "No"
  hit_examples = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
  for i in range(3):
    a.extend(list(map(int, input().split())))
  n = int(input())
  b = []
  for i in range(n):
    b.append(int(input()))
  for b_value in b:
    for i in range(len(a)):
      if b_value == a[i]:
        a[i] = -1

  for hit_example in hit_examples:
    for i in range(len(a)):
      if a[i] == -1 and i in hit_example:
        ans = "Yes"
        print(ans)
        return
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  a = []
  ans = "No"
  hit_examples = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
  for i in range(3):
    a.extend(list(map(int, input().split())))
  n = int(input())
  b = []
  for i in range(n):
    b.append(int(input()))
  for b_value in b:
    for i in range(len(a)):
      if b_value == a[i]:
        a[i] = -1
  
  for hit_example in hit_examples:
    for i in range(len(a)):
      if a[i] == -1 and i in hit_example:
        ans = "Yes"
        return
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
a = []
ans = "No"
hit_examples = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
for i in range(3):
  a.extend(list(map(int, input().split())))
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))
for b_value in b:
  for i in range(len(a)):
    if b_value == a[i]:
      a[i] = -1

for hit_example in hit_examples:
  for i in range(len(a)):
    if a[i] == -1 and i in hit_example:
      ans = "Yes"
      break
    else:
      continue
  break
print(ans)

Submission status: Wrong Answer

Solution code:
a = []
ans = "No"
hit_examples = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]
for i in range(3):
  a.extend(list(map(int, input().split())))
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))
for b_value in b:
  for i in range(len(a)):
    if b_value == a[i]:
      a[i] = -1

for hit_example in hit_examples:
  for i in range(len(a)):
    print(i in hit_example, a[i] == -1)
    if a[i] == -1 and i in hit_example:
      ans = "Yes"
      break
    else:
      continue
  break
print(ans)

Submission status: Wrong Answer

Solution code:
t = [0] * 3
x = [0] * 3
y = [0] * 3
a=[]
for i in range(3):
    t[i], x[i], y[i] = map(int, input().split())
a.append(t)
a.append(x)
a.append(y)#二重のリストへ
n=int(input())
li=[input() for i in range(n)]
#メインコード
ctr=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    for j in range(3):
        for k in range(n):#それぞれのリストを探索
            if int(a[i][j])==int(li[k]):#intとintの比較なので注意
                ctr[i][j]+=1
print(ctr)
if ctr[0][0]==ctr[0][1]==ctr[0][2]==1:
    print('Yes')
elif ctr[1][0]==ctr[1][1]==ctr[1][2]==1:
    print('Yes')
elif ctr[2][0]==ctr[2][1]==ctr[2][2]==1:
    print('Yes')
elif ctr[0][0]==ctr[1][0]==ctr[2][0]==1:
    print('Yes')
elif ctr[0][1]==ctr[1][1]==ctr[2][1]==1:
    print('Yes')
elif ctr[0][2]==ctr[1][2]==ctr[2][2]==1:
    print('Yes')
elif ctr[0][0]==ctr[1][1]==ctr[2][2]==1:
    print('Yes')
elif ctr[0][2]==ctr[1][1]==ctr[2][0]==1:
    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 = []

for n in range(int(input())):
    # b.append(int(input()))
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == a[i][j]:
                a[i][j] = 0

for i in range(3):
    if set([0]) == set(a[i]):
        print('Yes')
        exit()
    elif set([0]) == set([a[i][0], a[i][1], a[i][2]]):
        print('Yes')
        exit()

if set([0]) == set([a[0][0], a[1][1], a[2][2]]):
    print('Yes')
    exit()
    
if set([0]) == set([a[2][0], a[1][1], a[0][2]]):
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

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

b = []

for n in range(int(input())):
    # b.append(int(input()))
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == a[i][j]:
                a[i][j] = 0

for i in range(3):
    if set([0]) == set(a[i]):
        print('Yes')
        exit()
    elif set([0]) == set([a[i][i], a[i][i], a[i][i]]):
        print('Yes')
        exit()

if set([0]) == set([a[0][0], a[1][1], a[2][2]]):
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

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

b = []

for n in range(int(input())):
    # b.append(int(input()))
    b = int(input())
    for i in range(3):
        for j in range(3):
            if b == a[i][j]:
                a[i][j] = 0

for i in range(3):
    if set([0]) == set(a[i]):
        print('Yes')
        exit()
    elif set([0]) == set([a[i][0], a[i][1], a[i][2]]):
        print('Yes')
        exit()

if set([0]) == set([a[0][0], a[1][1], a[2][2]]):
    print('Yes')
    exit()

print('No')

Submission status: Wrong Answer

Solution code:
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import statistics
import string


def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

card = [[0] * 3 for i in range(3)]
bingo = [[0] * 3 for i in range(3)]
flag = 0
for i in range(3):
    card[i][0],  card[i][1], card[i][2] = splitintinput()

N = intinput()
for i in range(N):
    b = intinput()
    for j in range(3):
        for k in range(3):
            if card[j][k] == b:
                bingo[j][k] = 1

for i in range(3):
    for j in range(3):
        if bingo[i][j] == 0:
            break
        flag = 1

for i in range(3):
    for j in range(3):
        if bingo[j][i] == 0:
            break
        flag = 1

for i in range(3):
    if bingo[i][i] == 0:
        break
    flag = 1

for i in range (3):
    if bingo[i][2-i] == 0:
        break
    flag = 1

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

Submission status: Wrong Answer

Solution code:
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import statistics
import string


def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

card = [[0] * 3 for i in range(3)]
bingo = [[0] * 3 for i in range(3)]
flag = 0
for i in range(3):
    card[i][0],  card[i][1], card[i][2] = splitintinput()

N = intinput()
for i in range(N):
    b = intinput()
    for j in range(3):
        for k in range(3):
            if card[j][k] == b:
                bingo[j][k] = 1

for i in range(3):
    for j in range(3):
        if bingo[i][j] == 0:
            break
        flag = 1

for i in range(3):
    for j in range(3):
        if bingo[j][i] == 0:
            break
        flag = 1

for i in range(3):
    if bingo[i][i] == 0:
        break
    flag = 1

for i in range (3):
    if bingo[i][2-i] == 0:
        break

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

Submission status: Wrong Answer

Solution code:
import sys

bingo=[]

for _ in range(3):
  bingo.append(list(map(int, input().split())))

n=int(input())

for i in range(n):
  a=int(input())
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == a:
        bingo[j][k]=0



for i in range(3):
  if bingo[i][0]==0 & bingo[i][1]==0 & bingo[i][2]==0:
    print('Yes')
    sys.exit()
  elif bingo[0][i]==0 & bingo[1][i]==0 & bingo[2][i]==0:
    print('Yes')
    sys.exit()

if bingo[0][0]==0 & bingo[1][1]==0 & bingo[2][2]==0:
  print('Yes')
  sys.exit()

if bingo[0][2]==0 & bingo[1][1]==0 & bingo[2][0]==0:
  print('Yes')
  sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

bingo=[]

for _ in range(3):
  bingo.append(list(map(int, input().split())))

n=int(input())

for i in range(n):
  a=int(input())
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == a:
        bingo[j][k]=0

#print(bingo)

for i in range(3):
  if bingo[i][0]==0 & bingo[i][1]==0 & bingo[i][2]==0:
    print('Yes')
    sys.exit()
  if bingo[0][i]==0 & bingo[1][i]==0 & bingo[2][i]==0:
    print('Yes')
    sys.exit()

if bingo[0][0]==0 & bingo[1][1]==0 & bingo[2][2]==0:
  print('Yes')
  sys.exit()

if bingo[0][2]==0 & bingo[1][1]==0 & bingo[2][0]==0:
  print('Yes')
  sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

bingo=[]

for _ in range(3):
  bingo.append(list(map(int, input().split())))

n=int(input())

for i in range(n):
  a=int(input())
  for j in range(3):
    for k in range(3):
      if bingo[j][k] == a:
        bingo[j][k]=0

print(bingo)

for i in range(3):
  if bingo[i][0]==0 & bingo[i][1]==0 & bingo[i][2]==0:
    print('Yes')
    sys.exit()
  if bingo[0][i]==0 & bingo[1][i]==0 & bingo[2][i]==0:
    print('Yes')
    sys.exit()

if bingo[0][0]==0 & bingo[1][1]==0 & bingo[2][2]==0:
  print('Yes')
  sys.exit()

if bingo[0][2]==0 & bingo[1][1]==0 & bingo[2][0]==0:
  print('Yes')
  sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
list1 = input().split()
list2 = input().split()
list3 = input().split()
n = int(input())

for _ in range(n):
    value = input()
    list1 = ['' if value in s else s for s in list1]
    list2 = ['' if value in s else s for s in list2]
    list3 = ['' if value in s else s for s in list3]
ans = 'No'
if all(s == '' for s in list1) or all(s == '' for s in list2) or all(s == '' for s in list3):
    ans = 'Yes'
for x, y, z in zip(list1, list2, list3):
    if all(s == '' for s in [x, y, z]):
        ans = 'Yes'
if list1[0] == '' and list2[1] == '' and list3[2] == '' or list1[2] == '' and list2[1] == '' and list3[0] == '':
    ans = 'Yes'
print(ans)

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

c = [[False]*3 for i 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] = True

flag = False

for i in range(3):
    if all(c[i]) == True:
        flag = True
    elif all(c[:][i]) == True:
        flag = True

if c[0][0] == c[1][1] == c[2][2] == True:
    flag = True
if c[0][2] == c[1][1] == c[2][0] == True:
    flag = True

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

Submission status: Wrong Answer

Solution code:
import numpy as np

A = []
a = [int(x) for x in input().split()]
A.append(a)
A_len = len(a)
state = True

for s in range(A_len - 1):
    A.append([int(x) for x in input().split()])

A = np.array(A)

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




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

for i in range(N):
    A = np.where(A==B[i], 0, A)


for i in range(A_len):
    if (A[i].sum() == 0) or (A[:,i].sum() == 0):
        print('Yes')
        exit()

    if (A[i,i] != 0) or (A[i,A_len-i-1] != 0):
        state = False

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

Submission status: Wrong Answer

Solution code:
import numpy as np

A = []
a = [int(x) for x in input().split()]
A.append(a)
A_len = len(a)
state = True

for s in range(A_len - 1):
    A.append([int(x) for x in input().split()])
    
A = np.array(A)

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


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

for i in range(N):
    A = np.where(A==B[i], 0, A)


for i in range(A_len):
    if (A[i].sum() == 0) or (A[:,i].sum() == 0):
        print('Yes')
        exit()

    if A[i,i] != 0:
        state = False

if state:
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
def contains(lista, n):
    for i in range(3):
        for j in range(3):
            if lista[i][j] == n:
                lista[i][j] = "x"

def busca(lista):
    for i in range(3):
        if(lista[i][0] == "x" and lista[i][1] == "x" and lista[i][2] == "x"):
           return "Yes"
    for i in range(3):
        if(lista[0][i] == "x" and lista[1][i] == "x" and lista[2][i] == "x"):
           return "Yes"
    if(lista[0][0] == "x" and lista[1][1] == "x" and lista[2][2] == "x"):
       return "Yes"
    if(lista[0][2] == "x" and lista[1][1] == "x" and lista[2][0] == "x"):
       return "Yes"
    return "No"

    
lista = []
for i in range(3):
    x = list(map(float,input().split()))
    lista.append(x)
for i in range(int(input())):
    b = float(input())
    contains(lista,b)
print(busca(lista))
print(lista)

Submission status: Wrong Answer

Solution code:
def contains(lista, n):
    for i in range(3):
        for j in range(3):
            if lista[i][j] == n:
                lista[i][j] = "x"

def busca(lista):
    for l in lista:
        if l == ["x","x","x"]:
            return "yes"
    for i in range(3):
        if(lista[0][i] == "x" and lista[1][i] == "x" and lista[2][i] == "x"):
           return "yes"
    if(lista[0][0] == "x" and lista[1][1] == "x" and lista[2][2] == "x"):
       return "yes"
    if(lista[0][2] == "x" and lista[1][1] == "x" and lista[2][0] == "x"):
       return "yes"
    return "no"

    
lista = []
for i in range(3):
    x = list(map(float,input().split()))
    lista.append(x)
for i in range(int(input())):
    b = float(input())
    contains(lista,b)
print(busca(lista))

Submission status: Wrong Answer

Solution code:
import math

a1 = list(map(int, input().rstrip().split()))
a2 = list(map(int, input().rstrip().split()))
a3 = list(map(int, input().rstrip().split()))
a = [a1,a2,a3]

m = [[0,0,0],[0,0,0],[0,0,0]]

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

if m[0].count(1) == 3 :
    print('Yes')
elif m[1].count(1) == 3 :
    print('Yes')
elif m[2].count(1) == 3 :
    print('Yes')
elif m[0][0] == 1 and m[1][0] == 1 and m[2][0] ==1 :
    print('YES')
elif m[0][1] == 1 and m[1][1] == 1 and m[2][1] ==1 :
    print('YES')
elif m[0][2] == 1 and m[1][2] == 1 and m[2][2] ==1 :
    print('YES')
elif m[0][0] == 1 and m[1][1] == 1 and m[2][2] ==1 :
    print('YES')
elif m[0][2] == 1 and m[1][1] == 1 and m[2][0] ==1 :
    print('YES')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
import math

a1 = list(map(int, input().rstrip().split()))
a2 = list(map(int, input().rstrip().split()))
a3 = list(map(int, input().rstrip().split()))
a = [a1,a2,a3]

m = [[0,0,0],[0,0,0],[0,0,0]]

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

if a[0].count(1) == 3 :
    print('Yes')
elif a[1].count(1) == 3 :
    print('Yes')
elif a[2].count(1) == 3 :
    print('Yes')
else :
    print('No')

Submission status: Wrong Answer

Solution code:
A = [[int(n) for n in input().split()] for _ in range(3)]
A = sum(A, [])
N = int(input())
B = [int(input()) for n in range(N)]
goal = [
    [1, 1, 1, 0, 0, 0, 0, 0, 0,],
    [0, 0, 0, 1, 1, 1, 0, 0, 0,],
    [0, 0, 0, 0, 0, 0, 1, 1, 1,],
    [1, 0, 0, 1, 0, 0, 1, 0, 0,],
    [0, 1, 0, 0, 1, 0, 0, 1, 0,],
    [0, 0, 1, 0, 0, 1, 0, 0, 1,],
    [1, 0, 0, 0, 1, 0, 0, 0, 1,],
    [0, 0, 1, 0, 1, 0, 1, 0, 0,],
]
bool = False
for b in B:
	if b in A:
		idx = A.index(b)
		c = 0
		for g in goal:
			c += g[idx]
		if c >= 3:
			print('Yes')
			bool = True
			break
	if bool:
		break
else:
	print('No')

Submission status: Wrong Answer

Solution code:
A = [[int(n) for n in input().split()] for _ in range(3)]
A = sum(A, [])
N = int(input())
B = [int(input()) for n in range(N)]
goal = [
    [1, 1, 1, 0, 0, 0, 0, 0, 0,],
    [0, 0, 0, 1, 1, 1, 0, 0, 0,],
    [0, 0, 0, 0, 0, 0, 1, 1, 1,],
    [1, 0, 0, 1, 0, 0, 1, 0, 0,],
    [0, 1, 0, 0, 1, 0, 0, 1, 0,],
    [0, 0, 1, 0, 0, 1, 0, 0, 1,],
    [1, 0, 0, 0, 1, 0, 0, 0, 1,],
    [0, 0, 1, 0, 1, 0, 1, 0, 0,],
]
bool = False
c = 0
for b in B:
	if b in A:
		idx = A.index(b)
		for g in goal:
			c += g[idx]
		if c >= 3:
			print('Yes')
			bool = True
			break
	if bool:
		break
else:
	print('No')

Submission status: Wrong Answer

Solution code:
A = [[int(n) for n in input().split()] for _ in range(3)]
A = sum(A, [])
N = int(input())
B = [int(input()) for n in range(N)]
goal = [
    [1, 1, 1, 0, 0, 0, 0, 0, 0,],
    [0, 0, 0, 1, 1, 1, 0, 0, 0,],
    [0, 0, 0, 0, 0, 0, 1, 1, 1,],
    [1, 0, 0, 1, 0, 0, 1, 0, 0,],
    [0, 1, 0, 0, 1, 0, 0, 1, 0,],
    [0, 0, 1, 0, 0, 1, 0, 0, 1,],
    [1, 0, 0, 0, 1, 0, 0, 0, 1,],
    [0, 0, 1, 0, 1, 0, 1, 0, 0,],
]
bool = False
for b in B:
	c = 0
	if b in A:
		idx = A.index(b)
		for g in goal:
			c += g[idx]
		if c >= 3:
			print('Yes')
			bool = True
			break
	if bool:
		break
else:
	print('No')

Submission status: Wrong Answer

Solution code:
A = [[int(n) for n in input().split()] for _ in range(3)]
A = sum(A, [])
N = int(input())
B = [int(input()) for n in range(N)]
goal = [
    [1, 1, 1, 0, 0, 0, 0, 0, 0,],
    [0, 0, 0, 1, 1, 1, 0, 0, 0,],
    [0, 0, 0, 0, 0, 0, 1, 1, 1,],
    [1, 0, 0, 1, 0, 0, 1, 0, 0,],
    [0, 1, 0, 0, 1, 0, 0, 1, 0,],
    [0, 0, 1, 0, 0, 1, 0, 0, 1,],
    [1, 0, 0, 0, 1, 0, 0, 0, 1,],
    [0, 0, 1, 0, 1, 0, 1, 0, 0,],
]
bool = False
for b in B:
	if b in A:
		c=0
		idx = A.index(b)
		for g in goal:
			c += g[idx]
		if c >= 3:
			print('Yes')
			bool = True
			break
	if bool:
		break
else:
	print('No')

Submission status: Wrong Answer

Solution code:
A = [[int(n) for n in input().split()] for _ in range(3)]
A = sum(A, [])
N = int(input())
B = [int(input()) for n in range(N)]
goal = [
    [1, 1, 1, 0, 0, 0, 0, 0, 0,],
    [0, 0, 0, 1, 1, 1, 0, 0, 0,],
    [0, 0, 0, 0, 0, 0, 1, 1, 1,],
    [1, 0, 0, 1, 0, 0, 1, 0, 0,],
    [0, 1, 0, 0, 1, 0, 0, 1, 0,],
    [0, 0, 1, 0, 0, 1, 0, 0, 1,],
    [1, 0, 0, 0, 1, 0, 0, 0, 1,],
    [0, 0, 1, 0, 1, 0, 1, 0, 0,],
]
bool = False
for b in B:
	if b in A:
		c=0
		idx = A.index(b)
		for g in goal:
			c += g[idx]
		if c >= 3:
			print('Yes')
			bool = True
			break
	if bool:
		break
if not bool:
	print('No')

Submission status: Wrong Answer

Solution code:
A = [[int(n) for n in input().split()] for _ in range(3)]
A = sum(A, [])
N = int(input())
B = [int(input()) for n in range(N)]
goal = [
    [1, 1, 1, 0, 0, 0, 0, 0, 0,],
    [0, 0, 0, 1, 1, 1, 0, 0, 0,],
    [0, 0, 0, 0, 0, 0, 1, 1, 1,],
    [1, 0, 0, 1, 0, 0, 1, 0, 0,],
    [0, 1, 0, 0, 1, 0, 0, 1, 0,],
    [0, 0, 1, 0, 0, 1, 0, 0, 1,],
    [1, 0, 0, 0, 1, 0, 0, 0, 1,],
    [0, 0, 1, 0, 1, 0, 1, 0, 0,],
]
b = False
for b in B:
	if b in A:
		c=0
		idx = A.index(b)
		for g in goal:
			c += g[idx]
		if c >= 3:
			print('Yes')
			b = True
			break
	if b:
		break
if not b:
    print('No')

Submission status: Wrong Answer

Solution code:
A_one = [int(i) for i in input().split()]
A_two = [int(i) for i in input().split()]
A_three = [int(i) for i in input().split()]

X = [0, 0, 0]
Y = [0, 0, 0]
Z = [0, 0, 0]
res = False
N = int(input())
for i in range(N):
    j = int(input())
    try:
        a = A_one.index(j)
    except:
        pass
    else:
        X[a] = 1
    
    try:
        a = A_two.index(j)
    except:
        pass
    else:
        Y[a] = 1

    try:
        a = A_three.index(j)
    except:
        pass
    else:
        Z[a] = 1

if sum(X) == 3 or sum(Y) == 3 or sum(Z) == 3: 
    res = True

if X[0] + Y[1] + Z[2] == 3:
    res = True

if X[2] + Y[1] + Z[0] == 3:
    res = True

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