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: Runtime Error

Solution code:
import sys

def main():
    a = [list(map(int,input().split())) for _ in range(3)]
    num = int(input())
    b = []
    for i in range(num):
        x = int(input())
        b.append(x)
    
    for i in range(3):
        for j in range(3):
            for n in range(num):
                if a[i][j] == b[n]:
                    a[i][j] = 0
                    break

    j = 0
    """
    for i in range(3):
        if a[i][j] == a[i][j+1] == a[i][j+2]:
            print("Yes")
            sys.exit()
        if a[j][i] == a[j+1][i] == a[j+2][i]:
            print("Yes")
            sys.exit()
        if i == 0:
            if a[i][j] == a[i+1][j+1] == a[i+2][j+2]:
                print("Yes")
                sys.exit()
        elif i == 2:
            if a[i][j+2] == a[i-1][j+1] == a[i-2][j]:
                print("Yes")
                sys.exit()
    print("No")
    """
    for i in range(3):
        if Bin[i][0]==Bin[i][1]==Bin[i][2]:
            flag = 1
    for i in range(3):
        if Bin[0][i]==Bin[1][i]==Bin[2][i]:
            flag = 1
    if Bin[0][0]==Bin[1][1]==Bin[2][2]:
        flag = 1
    if Bin[2][0]==Bin[1][1]==Bin[0][2]:
        flag = 1    
    if flag == 1:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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()))
  
bingo = [[0,0,0],[0,0,0],[0,0,0]]
cnt = [0,0,0]
for b in B:
  for a, i in enumerate(A):
    for aa, j in enumerate(a):
      if aa == b:
        bingo[i][j] = 1
        cnt[j] += 1
for v in bingo:
  if v.count(1) == 3:
    print('Yes')
    exit()
if 3 in cnt:
  print('Yes')
elif bingo[0][0] == 1 and bingo[1][1] == 1 and bingo[2][2] == 1:
  print('Yes')
elif bingo[0][2] == 1 and bingo[1][1] == 1 and bingo[2][0] == 1:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

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

bingo = {0:[],1:[],2:[]}
cnt = {0:0,1:0,2:0}
for b in B:
  for a, i in enumerate(A):
    for aa, j in enumerate(a):
      if b == aa:
        bingo[i].append(j)
        cnt[j] += 1
for v in bingo.values():
  if len(v) == 3:
    print('Yes')
    exit()
if 3 in cnt.values():
  print('Yes')
elif 0 in bingo[0] and 1 in bingo[1] and 2 in bingo[2]:
  print('Yes')
elif 2 in bingo[0] and 1 in bingo[1] and 0 in bingo[2]:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
A = []
for _ in range(3):
    A = list(map(int, input().split()))
N = int(input())
B = [int(input()) for i in range(N)]
for i in range(N):
    for j in range(9):
        if B[i] ==  A[j] :
            A[j] = 'a'
if A[0]==A[1]==A[2]=='a' or A[3]==A[4]==A[5]=='a' or A[6]==A[7]==A[8]=='a' or A[0]==A[3]==A[6]=='a' or A[1]==A[4]==A[7]=='a' or A[2]==A[5]==A[8]=='a' or  A[0]==A[4]==A[8]=='a' or A[2]==A[4]==A[6]=='a' :
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
bingo = []
b = []

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

n = int(input())

while True:
  try:
    b.append(int(input()))
  except EOFError:
    break

lis1 = [bingo[0][0],bingo[0][1],bingo[0][2]]
lis2 = [bingo[1][0],bingo[1][1],bingo[1][2]]
lis3 = [bingo[2][0],bingo[2][1],bingo[2][2]]

lis4 = [bingo[0][0],bingo[1][0],bingo[2][0]]
lis5 = [bingo[0][1],bingo[1][1],bingo[2][1]]
lis6 = [bingo[0][2],bingo[1][2],bingo[2][2]]

lis7 = [bingo[0][0],bingo[1][1],bingo[2][2]]
lis8 = [bingo[0][2],bingo[1][1],bingo[2][0]]


print(allList)
for i in allList:
  cnt = 0
  for _ in range(3):
    if i[_] in b:
      cnt +=1
  if cnt ==3:
    print("Yes")
    exit()
print("No")

Submission status: Runtime Error

Solution code:
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
flag = False
for i in range(3):
    if all(a[i][j] in b for j in range(3)): #bの中にa[i][j]があるかどうか
        flag = True
    if all(a[j][i] in b for j in range(3)):
        flag = True
if all(a[i][i] in b for i in range(3)) or all(a[i][2-i] in b for i in range(3)):
    flag = True
 
if flag:
    print("Yes")
else:

Submission status: Runtime Error

Solution code:
lst1 = [int() for i in input().split()]
lst2 = [int() for i in input().split()]
lst3 = [int() for i in input().split()]
n = int(input())
b = [int(input()) for i in range(n)]
lst4 = [lst1[0], lst2[0], lst3[0]]
lst5 = [lst1[1], lst2[1], lst3[1]]
lst6 = [lst1[2], lst2[2], lst3[2]]
lst7 = [[lst1[0], lst2[1], lst3[2]]]
lst8 = [[lst1[2], lst2[1], lst3[0]]]
if len(set(b) & set(lst4)) == 3:
    print('Yes')
elif len(set(b) & set(lst5)) == 3:
    print('Yes')
elif len(set(b) & set(lst6)) == 3:
    print('Yes')
elif len(set(b) & set(lst7)) == 3:
    print('Yes')
elif len(set(b) & set(lst8)) == 3:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
a = [list(map(int, input().split())) for _ in range(3)]
is_bingo = [[False]*3 for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for i, ai in enumerate(a):
        for j, aii in enumerate(ai):
            if aii == b:
                is_bingo[i][j] = True
is_bingo_flat = [j for i in is_bingo for j in i]
for i in range(3):
    if all(is_bingo[i]) or all(list(zip(*is_bingo))[i]):
        print("Yes")
        break
else:
    if all(is_bingo_flat[::3]) or all(is_bingo_flat[2:7::2]):
        print("Yes")
    print("No")

Submission status: Runtime Error

Solution code:
res = False
for row in a:
    if all(num in b for num in row):
        res = True
for col in zip(a):
    if all(num in b for num in col):
        res = True
if all(a[i][i] in b for i range(3)):
        res = True
if all(a[i][2 - i] in b for i range(3)):
        res = True


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

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

a = np.array([sys.stdin.readline().split() for _ in range(3)], dtype=np.int64)
n = int(sys.stdin.readline().rstrip())
b = np.array(sys.stdin.read().split(), dtype=np.int64)
def main():
    c = np.isin(a, b)
    bl1 = np.any(np.all(c, axis=1))
    bl2 = np.any(np.all(c, axis=0))
    bl3 = np.all(np.diagonal(c))
    bl4 = np.all(np.diagonal(np.fliplr(c)))
    bl = bl1 | bl2 | bl3 | bl4
    print('Yes' if bl else 'No')

if __name__ ==  '__main__':
    main()

Submission status: Runtime Error

Solution code:
card = [[int(x) for x in input().split()] for y in range(3)]
bools = [[0,0,0],[0,0,0],[0,0,0]]
n = int(input())
for _ in range(n):
  x = int(input())
  for i in range(3):
    for j in range(3):
      if x == card[i][j]:
        bools[i][j] = 1
ok = False
for i in range(3):
  if (bools[i][0], bools[i][1], bools[i][2]) == (1,1,1) or 
  (bools[0][i], bools[1][i], bools[2][i]) == (1,1,1):
    ok = True
if (bools[0][0],bools[1][1],bools[2][2]) == (1,1,1) or (bools[0][2], bools[1][1], bools[2][0]) == (1,1,1):
  ok = True
print("Yes" if ok else "No")

Submission status: Runtime Error

Solution code:
i1 = int(input())
i2 = int(input())
i3 = int(input())
i4 = int(input())
i5 = int(input())
i6 = int(input())
i7 = int(input())
i8 = int(input())
i9 = int(input())

ar1 = [i1, i2, i3]
ar2 = [i4, i5, i6]
ar3 = [i7, i8, i9]
ar4 = [i1, i4, i7]
ar5 = [i2, i5, i8]
ar6 = [i3, i6, i9]
ar7 = [i1, i5, i9]
ar8 = [i3, i5, i7]

n = int(input())

for i in range(n):
    b = int(input())
    try:
        ar1.remove(b)
    except ValueError:
        pass
    try:
        ar2.remove(b)
    except ValueError:
        pass
    try:
        ar3.remove(b)
    except ValueError:
        pass
    try:
        ar4.remove(b)
    except ValueError:
        pass
    try:
        ar5.remove(b)
    except ValueError:
        pass
    try:
        ar6.remove(b)
    except ValueError:
        pass
    try:
        ar7.remove(b)
    except ValueError:
        pass
    try:
        ar8.remove(b)
    except ValueError:
        pass

if not ar1 or not ar2 or not ar3 or not ar4 or not ar5 or not ar6 or not ar7 or not ar8:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
i1 = int(input())
i2 = int(input())
i3 = int(input())
i4 = int(input())
i5 = int(input())
i6 = int(input())
i7 = int(input())
i8 = int(input())
i9 = int(input())

ar1 = [i1, i2, i3]
ar2 = [i4, i5, i6]
ar3 = [i7, i8, i9]
ar4 = [i1, i4, i7]
ar5 = [i2, i5, i8]
ar6 = [i3, i6, i9]
ar7 = [i1, i2, i3]
ar8 = [i1, i2, i3]

n = int(input())

for i in range(n):
    b = int(input())
    ar1.remove(b)
    ar2.remove(b)
    ar3.remove(b)
    ar4.remove(b)
    ar5.remove(b)
    ar6.remove(b)
    ar7.remove(b)
    ar8.remove(b)

if not ar1 or not ar2 or not ar3 or not ar4 or not ar5 or not ar6 or not ar7 or not ar8:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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 j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k]=0

for i in range(3):
    flag=True
    for j in range(3):
        if a[i][j]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

for i in range(3):
    flag=True
    for j in range(3):
        if a[j][i]!=0:
            flag=False
    if flag:
        print("Yes")
        exit()

for i in range(3):
    flag=True
    if a[i][i]!=0:
        flag=False
if flag:
    print("Yes")
    exit()

for i in range(3):
    if a[i][3-i]!=0:
        print("No")
        exit()
print("Yes")
exit()

Submission status: Runtime Error

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

n  = int(input())
br = 0
for i in range(1,n+1): 
    br = int(input())
    if br in lst:
         pass
    elif !(br in lst):
        print("No")
        break
    elif i == n:
        print("Yes")

Submission status: Runtime Error

Solution code:
 = input().split()
b = input().split()
c = input().split()
list_ans =(a,b,c)
N = int(input())
bingo_list=[]

for i in range(N):
    bingo = input()
    bingo_list.append(bingo)


#横ビンゴ判定
def bingo_row(p,q):
    row_total= 0
    #p 横のリスト　q 出た値のリスト
    for i in range(3):
        if p[i] in q:
            row_total +=1
        else:
            return False
    if row_total == 3:
        return True
#縦ビンゴ判定
def bingo_column(p,q,r,s):
    batu = 0
    #pqr横リスト　s bingo_list
    for i in range(3):
        
        if p[i]  in s and q[i] in s:
            if r[i] in s:
                return True
                break
            else:
                batu +=1 
        else:
            batu +=1
    if batu == 3:
        return False
#斜めビンゴ判定
def bingo_slash(p,q,r,s):
    if q[1] in s:
        if p[0] in s and r[2] in s:
            print('C')
            return True
        elif p[2] in s and r[0] in s:
            print('D')
            return True
        else:
            return False
    else:
        return False

    
total = 0
for i in list_ans:
    if bingo_row(i, bingo_list):
        print('Yes')
        break
    elif bingo_column(a,b,c,bingo_list):
        print('Yes')
        break
    elif bingo_slash(a,b,c,bingo_list):
        print('Yes')
        break
    else:
        total += 1
if total == 3:
    print('No')

Submission status: Runtime Error

Solution code:
a = input().split()
b = input().split()
c = input().split()
list_ans =(a,b,c)
N = int(input())
bingo_list=[]

for i in range(N):
    bingo = input()
    bingo_list.append(bingo)
    
#横ビンゴ判定
def bingo_row(p,q):
    #p 横のリスト　q 出た値のリスト
    for i in range(3):
        if p[i] in q:
            return True
        else:
            return False
#縦ビンゴ判定
def bingo_column(p,q,r,s):
    batu = 0
    #pqr横リスト　s bingo_list
    for i in range(4):
        
        if p[i]  in s and q[i] in s:
            if r[i] in s:
                return True
                break
            else:
                batu +=1 
        else:
            batu +=1
    if batu == 3:
        return False
#斜めビンゴ判定
def bingo_slash(p,q,r,s):
    if q[1] in s:
        if p[0] in s and r[2] in s:
            return True
        elif p[2] in s and r[0] in s:
            return True
        else:
            return False
    else:
        return False

    
total = 0
for i in list_ans:
    if bingo_row(i, bingo_list):
        print('Yes')
        break
    elif bingo_column(a,b,c,bingo_list):
        print('Yes')
        break
    elif bingo_slash(a,b,c,bingo_list):
        print('Yes')
        break
    else:
        total += 1
if total == 3:
    print('No')

Submission status: Runtime Error

Solution code:
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
b = [0] * N 
for i in range(N):
    b[i] = int(input())
A = [A1,A2,A3]
B = [[0]*3,[0]*3,[0]*3]
for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] == b[k]:
                B[i][j] = 1
if B[0] == [1,1,1]:
    print("Yes")
elif B[1] == [1,1,1]:
    print("Yes")
elif B[2] == [1,1,1]:
    print("Yes")
elif B[0][0] == 1 and B[1][0] == 1 and B[2][0] == 1:
    print("Yes")
elif B[0][1] == 1 and B[1][1] == 1 and B[2][1] == 1:
    print("Yes")
elif B[0][2] == 1 and B[1][2] == 1 and B[2][2] == 1:
    print("Yes")
elif B[0][0] == 1 and B[1][1] == 1 and B[2][2] == 1:
    print("Yes")
elif B[0][2] == 1 and B[1][1] == 1 and B[2][0] == 1:
    print("Yes")
else:
    print("No"

Submission status: Runtime Error

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

print(A1)

Submission status: Runtime Error

Solution code:
list1=[]
A1,A2,A3=map(int,input().split())
A4,A5,A6=map(int,input().split())
A7,A8,A9=map(int,input().split())
N=int(input())
for i in range(1,N+1):
    list1.append(int(input()))

list2=[A1,A2,A3,
    A4,A5,A6,
    A7,A8,A9]
for x in range(N):
    if (list1[x] in list2)==True:
        list2[x]="Bingo"
    elif (list1[x] in list2)==False:
        list2[x]="Not-Bingo"

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

Submission status: Runtime Error

Solution code:
list1=[]
A1,A2,A3=map(int,input().split())
A4,A5,A6=map(int,input().split())
A7,A8,A9=map(int,input().split())
N=int(input())
for i in range(1,N+1):
    list1.append(int(input()))

list2=[A1,A2,A3,
    A4,A5,A6,
    A7,A8,A9]
for x in range(N):
    if (list1[x] in list2)==True:
        list2[x]="Bingo"
    else:list2[x]="Not-Bingo"

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

else:print("No")

Submission status: Runtime Error

Solution code:
l=[]
for i in range(3):
  l.append(list(map(int,input().split())))
n=int(input())
l1=[]
for i in range(n):
  l1.append(int(input())
for i in range(len(l)):
    for j in range(len(l)):
        if(l[i][j] in l1):
            l[i][j]=0
f=0
if((l[0][0]==0 and l[0][1]==0 and l[0][2]==0) or (l[1][0]==0 and l[1][1]==0 and l[1][2]==0) or (l[2][0]==0 and l[2][1]==0 and l[2][2]==0))
    f=1
elif((l[0][0]==0 and l[1][0]==0 and l[2][0]==0) or (l[0][1]==0 and l[1][1]==0 and l[2][1]==0) or (l[0][2]==0 and l[1][2]==0 and l[2][2]==0))
    f=1
elif((l[0][0]==0 and l[1][1]==0 and l[2][2]==0) or (l[0][2]==0 and l[1][1]==0 and l[2][0]==0)):
    f=1
if(f==1):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
list1=[]
A1,A2,A3=map(int,input().split())
A4,A5,A6=map(int,input().split())
A7,A8,A9=map(int,input().split())
N=int(input())
for i in range(1,N+1):
    list1.append(int(input()))

list2=[A1,A2,A3,
    A4,A5,A6,
    A7,A8,A9]
for x in range(N):
    if (list1[x] in list2)==True:
        list2[x]="Bingo"
    else:list2[x]="Not-Bingo"

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

Submission status: Runtime Error

Solution code:
list1=[]
A1,A2,A3=map(int,input().split())
A4,A5,A6=map(int,input().split())
A7,A8,A9=map(int,input().split())
N=int(input())
for i in range(1,N+1):
    list1.append(int(input()))

list2=[A1,A2,A3,
    A4,A5,A6,
    A7,A8,A9]
for x in range(N):
    if (list1[x] in list2)==True:
        list2[x]="Bingo"
    else:list2[x]="Not-Bingo"

if list2[0]==list2[1]==list2[2]:
    print("Yes")
if list2[0]==list2[3]==list2[6]:
    print("Yes")
if list2[3]==list2[4]==list2[5]:
    print("Yes")
if list2[6]==list2[7]==list2[8]:
    print("Yes")
if list2[1]==list2[4]==list2[7]:
    print("Yes")
if list2[2]==list2[5]==list2[8]:
    print("Yes")
if list2[0]==list2[4]==list2[8]:
    print("Yes")
if list2[2]==list2[4]==list2[6]:
    print("Yes")

Submission status: Runtime Error

Solution code:
list1=[]
A1,A2,A3=map(int,input().split())
A4,A5,A6=map(int,input().split())
A7,A8,A9=map(int,input().split())
N=int(input())
for i in range(1,N+1):
    list1.append(int(input()))

list2=[A1,A2,A3,
    A4,A5,A6,
    A7,A8,A9]
for x in range(N):
    if (list1[x] in list2)==True:
        list2[x]="Bingo"
    else:list2[x]="Not-Bingo"

if list2[0]==list2[1]==list2[2]:
    print("Yes")
if list2[0]==list2[3]==list[6]:
    print("Yes")
if list2[3]==list[4]==list[5]:
    print("Yes")
if list2[6]==list[7]==list[8]:
    print("Yes")
if list2[1]==list[4]==list[7]:
    print("Yes")
if list2[2]==list[5]==list[8]:
    print("Yes")
if list2[0]==list2[4]==list[8]:
    print("Yes")
if list2[2]==list[4]==list[6]:
    print("Yes")

Submission status: Runtime Error

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

bingo1 =[0,0,0]
bingo2 =[0,0,0]
bingo3 =[0,0,0]
for i in range(3):
    for j in range(N):
        if A1[i]=b[j]:
            bingo1[i]+=1
        if A2[i]=b[j]:
            bingo2[i]+=1
        if A3[i]=b[j]:
            bingo3[i]+=1
if bingo1[0] == 1 and bingo1[1] == 1 and bingo1[2] == 1:
    print("Yes")
elif bingo2[0] == 1 and bingo2[1] == 1 and bingo2[2] == 1:
    print("Yes")
elif bingo3[0] == 1 and bingo3[1] == 1 and bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == 1 and bingo2[0] == 1 and bingo3[0] == 1:
    print("Yes")
elif bingo1[1] == 1 and bingo2[1] == 1 and bingo3[1] == 1:
    print("Yes")
elif bingo1[2] == 1 and bingo2[2] == 1 and bingo3[2] == 1:
    print("Yes")
elif bingo1[1] == 1 and bingo2[2] == 1 and bingo3[3] == 1:
    print("Yes")
elif bingo1[3] == 1 and bingo2[2] == 1 and bingo3[1] == 1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

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

print(a)

if (a[0][0] == 0 and a[2][2] == 0 and a[1][1] == 0) or (a[0][2] == 0 and a[2][0] == 0 and a[1][1] == 0): #斜めに揃っていたら
  print("Yes")
  x = 1
for i in range(3):
  if a[i][0] == 0 and a[i][1] == 0 and a[i][2] and x == 0: #横に揃っていたら
    print("Yes")
    x = 1
    break
  elif a[0][i] == 0 and a[1][i] == 0 and a[2][i] and x == 0: #縦に揃っていたら
    print("Yes")
    x = 1
    break
if x == 0:
  print("No")a=[]
for i in range(3):
  a.append(list(map(int,input().split())))
n = int(input())
x = 0

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

if (a[0][0] == 0 and a[2][2] == 0 and a[1][1] == 0) or (a[0][2] == 0 and a[2][0] == 0 and a[1][1] == 0): #斜めに揃っていたら
  print("Yes")
  x = 1
for i in range(3):
  if a[i][0] == 0 and a[i][1] == 0 and a[i][2] and x == 0: #横に揃っていたら
    print("Yes")
    x = 1
    break
  elif a[0][i] == 0 and a[1][i] == 0 and a[2][i] and x == 0: #縦に揃っていたら
    print("Yes")
    x = 1
    break
if x == 0:
  print("No")

Submission status: Runtime Error

Solution code:
a1=[map(int(),input().split())]
a2=[map(int(),input().split())]
a3=[map(int(),input().split())]
n=int(input())
b=[input() for i in range(n)]
for i in range(3):
    for j in range(n):
        if a1[i] == b[j]:
            a1[i] = 1
        elif a2[i] == b[j]:
            a2[i] = 1
        elif a3[i] == b[j]:
            a3[i] = 1
 
if a1[0] == a1[1] == a1[2]:
    print("Yes")
elif a2[0] == a2[1] == a2[2]:
    print("Yes")
elif a3[0] == a3[1] == a3[2]:
    print("Yes")
elif a1[0] == a2[0] == a3[0]:
    print("Yes")
elif a1[1] == a2[1] == a3[1]:
    print("Yes")
elif a1[2] == a2[2] == a3[2]:
    print("Yes")
elif a1[0] == a2[1] == a3[2]:
    print("Yes")
elif a1[2] == a2[1] == a3[0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a1=[map(int(),input().split())]
a2=[map(int(),input().split())]
a3=[map(int(),input().split())]
n=int(input())
b=[input() for i in range(n)]
for i in range(3):
    for j in range(N):
        if a1[i] == b[j]:
            a1[i] = 1
        elif a2[i] == b[j]:
            a2[i] = 1
        elif a3[i] == b[j]:
            a3[i] = 1
 
print(line1)
print(line2)
print(line3)

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

Submission status: Runtime Error

Solution code:
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [(int(input())) for _ in range(N)]
for i in range(3):
    for j in range(N):
        if A_1[i] == b[j]:
            A_1[i] = 1
        elif A_2[i] == b[j]:
            A_2[i] = 1
        elif A_3[i] == b[j]:
            A_3[i] = 1


if 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_3[0] == A_3[1] == A_3[2]:
    print("Yes")
elif A_1[0] == A_2[0] == A_3[0]:
    print("Yes")
elif A_1[1] == A_2[1] == A_3[1]:
    print("Yes")
elif A_1[2] == A_2[2] == A_3[3]:
    print("Yes")
elif A_1[0] == A_2[1] == A_3[2]:
    print("Yes")
elif A_1[2] == A_2[1] == A_3[0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [(int(input())) for _ in range(N)]
for i in range(3):
    for j in range(N):
        if A_1[i] == b[j]:
            A_1[i] = "a"
        elif A_2[i] == b[j]:
            A_2[i] = "a"
        elif A_3[i] == b[j]:
            A_3[i] = "a"
print(A_1, A_2, A_3)

if 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_3[0] == A_3[1] == A_3[2]:
    print("Yes")
elif A_1[0] == A_2[0] == A_3[0]:
    print("Yes")
elif A_1[1] == A_2[1] == A_3[1]:
    print("Yes")
elif A_1[2] == A_2[2] == A_3[3]:
    print("Yes")
elif A_1[0] == A_2[1] == A_3[2]:
    print("Yes")
elif A_1[2] == A_2[1] == A_3[0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [list(map(int, input().split()))for _ in range(N)]
for i in range(3):
    for j in range(N):
        if A_1[i] == b[j][0]:
            A_1[i] = "a"
        elif A_2[i] == b[j][0]:
            A_2[i] = "a"
        elif A_3[i] == b[j][0]:
            A_3[i] = "a"
print(A_1, A_2, A_3)

if 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_3[0] == A_3[1] == A_3[2]:
    print("Yes")
elif A_1[0] == A_2[0] == A_3[0]:
    print("Yes")
elif A_1[1] == A_2[1] == A_3[1]:
    print("Yes")
elif A_1[2] == A_2[2] == A_3[3]:
    print("Yes")
elif A_1[0] == A_2[1] == A_3[2]:
    print("Yes")
elif A_1[2] == A_2[1] == A_3[0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [list(map(int, input().split()))for _ in range(N)]
for i in range(3):
    for j in range(N):
        if A_1[i] == b[j][0]:
            A_1[i] = "a"
        elif A_2[i] == b[j][0]:
            A_2[i] = "a"
        elif A_3[i] == b[j][0]:
            A_3[i] = "a"


if A_1[0] == A_1[1] == A_1[2] or A_2[0] == A_2[1] == A_2[2] or A_3[0] == A_3[1] == A_3[2] or A_1[0] == A_2[0] == A_3[0] or A_1[1] == A_2[1] == A_3[1] or A_1[2] == A_2[2] == A_3[3] or A_1[0] == A_2[1] == A_3[2] or A_1[2] == A_2[1] == A_3[0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [list(map(int, input().split()))for _ in range(N)]
for i in range(3):
    for j in range(N):
        if A_1[i] == b[j][0]:
            A_1[i] = "a"
        elif A_2[i] == b[j][0]:
            A_2[i] = "a"
        elif A_3[i] == b[j][0]:
            A_3[i] = "a"
        else:
            pass
if A_1[0] == A_1[1] == A_1[2] or A_2[0] == A_2[1] == A_2[2] or A_3[0] == A_3[1] == A_3[2] or A_1[0] == A_2[0] == A_3[0] or A_1[1] == A_2[1] == A_3[1] or A_1[2] == A_2[2] == A_3[3] or A_1[0] == A_2[1] == A_3[2] or A_1[2] == A_2[1] == A_3[0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
N = int(input())
b = [list(map(int, input().split()))for _ in range(N)]
for i in range(3):
    for j in range(N):
        if A_1[i] == b[j][0]:
            A_1[i] = "*"
        elif A_2[i] == b[j][0]:
            A_2[i] = "*"
        elif A_3[i] == b[j][0]:
            A_3[i] = "*"
        else:
            pass
if A_1[0] == A_1[1] == A_1[2] or A_2[0] == A_2[1] == A_2[2] or A_3[0] == A_3[1] == A_3[2] or A_1[0] == A_2[0] == A_3[0] or A_1[1] == A_2[1] == A_3[1] or A_1[2] == A_2[2] == A_3[3] or A_1[0] == A_2[1] == A_3[2] or A_1[2] == A_2[1] == A_3[0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import sys
A1 = list(map(int, sys.stdin.readline().split()))
A2 = list(map(int, sys.stdin.readline().split()))
A3 = list(map(int, sys.stdin.readline().split()))
N = int(sys.stdin.readline())
b = [int(sys.stdin.readline()) for _ in range(N)]
A = A1 + A2 + A3
i = 0
while i <= 8:
  if b.count(A[i]):
    A[i] = 101
  i += 1
bingoFlag = False
k = 0
while k <= 2:
  if A[k] == A[k+3] == A[k+6]:
    bingoFlag = True
    break
  k += 1
if A[0] == A[4] == A[8] or A[2] == A[4] == A[6]:
  bingoFlag = True
if bingFlag:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
A=[list(map(int,input().split())) for _ in range(3)]
N=int(input())
bn=[int(input()) for _ in range(N)]
ans=False
for ver in zip(*A):
    if all(item in bn for item in ver):
        ans=True
for wide in A:
    if all(item in bn for item in wide):
        ans=True
if all(A[i][i] in bn for i in range(3)):
    ans=True
if all(A[i][3-i] in bn for i in range(3)):
    ans=True
if ans==True:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

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

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