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:
a, b, c = map(int,input().split())
d, e, f = map(int,input().split())       
g, h, i = map(int,input().split())  
n = int(input())
s = []
for i in range(n):

Submission status: Runtime Error

Solution code:
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = list(map(int(input())))
import numpy as np
A = np.array(A)
l = []
for i in range(N):
  if b[i] in A:
    l.append(tuple(nd[0] for nd in np.where(A == b[i])))
if (0, 0) in l and (1, 0) in l and (2, 0) in l:
  print("Yes")
elif (0, 0) in l and (1, 1) in l and (2, 2) in l:
  print("Yes")
elif (0, 1) in l and (1, 1) in l and (2, 1) in l:
  print("Yes")
elif (0, 2) in l and (1, 1) in l and (2, 0) in l:
  print("Yes")
elif (0, 2) in l and (1, 2) in l and (2, 2) in l:
  print("Yes")
elif (0, 0) in l and (0, 1) in l and (0, 2) in l:
  print("Yes")
elif (1, 0) in l and (1, 1) in l and (1, 2) in l:
  print("Yes")
elif (2, 0) in l and (2, 1) in l and (2, 2) in l:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
//Generated at 2020-03-01 20:59:55 UTC+8
//Created by Alphagocc
#include<bits/stdc++.h>
#ifdef USE_PBDS
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#endif
#define FORCE_INLINE __inline__ __attribute__((always_inline))
class IO
{
static const int bufSize=1<<18;char inBuf[bufSize],outBuf[bufSize];char*ip1=inBuf,*ip2=inBuf;int goodReadBit=0,op1=-1,op2=bufSize-1;
template <typename T>FORCE_INLINE void __RI(T&x){int ch=gc(),neg=1;x=0;for(;!(isdigit(ch)||ch=='-'||ch==EOF);ch=gc());if(ch==EOF){goodReadBit=0;return;}if(ch=='-')neg=-1,ch=gc();for(;isdigit(ch);ch=gc())x=x * 10 +(ch - 48) * neg;}
template <typename T>FORCE_INLINE void __RC(T&x){unsigned char ch;while(isspace(ch=gc()));x=ch;}
FORCE_INLINE void __RS(std::string&x){char ch;x.clear();for(ch=gc();isspace(ch);ch=gc());if(ch==EOF){goodReadBit=0;return;}for(;!isspace(ch);ch=gc())x.push_back(ch);}
public:
FORCE_INLINE int gc(){return ip1==ip2 &&(ip2 =(ip1=inBuf)+fread(inBuf,1,bufSize,stdin),ip1==ip2)? EOF: *ip1++;}
FORCE_INLINE void R(char&x){__RC(x);}FORCE_INLINE void R(unsigned char&x){__RC(x);}FORCE_INLINE void R(std::string&x){__RS(x);}
template <typename T1,typename T2>FORCE_INLINE void R(std::pair<T1,T2>&x){R(x.first),R(x.second);}template <typename T>FORCE_INLINE void R(std::vector<T>&x){for(auto it=x.begin();it != x.end();++it)R(*it);}
template <typename T,typename...Args>FORCE_INLINE void RA(T*a,int n){for(int i=0;i < n;++i)R(a[i]);}template <typename T,typename...Args>FORCE_INLINE void R(T&x,Args&...args){R(x),R(args...);}
template <typename T,typename...Args>FORCE_INLINE void RA(T*a,int n,Args...args){for(int i=0;i < n;++i)RA(a[i],args...);}template <typename T>FORCE_INLINE void R(T&x){static_assert(std::is_integral<T>::value,"Unsupported types");if(std::is_integral<T>::value)__RI(x);}
private:
char space;template <typename T>FORCE_INLINE void __WI(T x){static char buf[64];static int len=-1;if(x >= 0){do{buf[++len]=x % 10+48,x /= 10;} while(x);} else{pc('-');do{buf[++len]=-(x%10)+48,x/=10;}while(x);}while(len>=0){pc(buf[len]),--len;}}
public:
FORCE_INLINE void pc(const char&x){if(op1==op2)flush();outBuf[++op1]=x;}
FORCE_INLINE void flush(){fwrite(outBuf,1,op1+1,stdout),op1=-1;}FORCE_INLINE void W(const char&x){pc(x);}FORCE_INLINE void W(const char* x){while(*x!='\0')pc(*(x++));}FORCE_INLINE void W(const std::string&x){W(x.c_str());}
template <typename T>FORCE_INLINE void W(const std::vector<T>&x){for(auto it=x.begin();it != x.end();it++)WS(*it);WL();}FORCE_INLINE void WL(){W('\n');}
template <typename T>FORCE_INLINE void WL(const T&x){W(x),W('\n');}FORCE_INLINE void WS(){W(' ');}
template <typename T>FORCE_INLINE void WS(const T&x){W(x),W(space);}
template <typename T>FORCE_INLINE void WA(T* a,int n){for(int i=0;i < n;i++)WS(a[i]);WL();}
template <typename T,typename...Args>FORCE_INLINE void W(const T&x,const Args&...args){W(x),W(space),W(args...);}
template <typename...Args>FORCE_INLINE void WL(const Args&...args){W(args...),W('\n');}
template <typename T,typename...Args>FORCE_INLINE void WA(T* a,int n,Args...args){for(int i=0;i < n;i++)WA(a[i],args...);}
template <typename T>FORCE_INLINE void W(const T&x){static_assert(std::is_integral<T>::value,"Unsupported types");if(std::is_integral<T>::value)__WI(x);}
template <typename T>FORCE_INLINE IO&operator>>(T&x){R(x);return(*this);}
template <typename T>FORCE_INLINE IO&operator<<(const T&x){W(x);return(*this);}IO(){space=' ';}
} io;
namespace Alphagocc{decltype(std::chrono::high_resolution_clock::now()) tStart;};void TimeBegin(){Alphagocc::tStart=std::chrono::high_resolution_clock::now();}long long TimeEnd(){return(std::chrono::high_resolution_clock::now() - Alphagocc::tStart).count();} // namespace Alphagocc
using namespace std;
#define REP(i,x,y) for(int i=x;i < y;i++)
const int8_t INFC=0x3f;
const int16_t INFS=0x3f3f;
const int32_t INF=0x3f3f3f3f;
const int64_t INFL=0x3f3f3f3f3f3f3f3fLL;

namespace Alphagocc
{
int MAIN()
{
    int n = 3;
    set<int> s;
    for (int i = 0; i < n * n; i++) {
        int x;
        io >> x;
        s.insert(x);
    }
    int q;
    io >> q;
    while (q--) {
        int x;
        io >> x;
        if (s.count(x)) {
            io.WL("YES"), io.flush();
            return 0;
        }
    }
    io.WL("NO");
    io.flush();
    return 0;
}
} // namespace Alphagocc
int main() { return Alphagocc::MAIN(); }

Submission status: Runtime Error

Solution code:
A = []
B = set()
ans = [[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
for i in range(N):
    B.add(int(input()))

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            ans[i][j] = 1

#ゴミコードだなぁ……

if ans[0][0] + ans[0][1] + ans[0][2] == 3:
    print('Yes')
elif ans[0][0] + ans[1][0] + ans[2][0] == 3:
    print('Yes')
elif ans[0][0] + ans[1][1] + ans[2][2] == 3:
    print('Yes')
elif ans[1][0] + ans[1][1] + ans[1][2] == 3:
    print('Yes')
elif ans[2][0] + ans[2][1] + ans[2][2] == 3:
    print('Yes')
elif ans[0][1] + ans[1][1] + ans[2][1] == 3:
    print('Yes')
elif ans[0][2] + ans[1][2] + ans[1][3] == 3:
    print('Yes')
elif ans[0][2] + ans[1][1] + ans[2][0] == 3:
    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()))
result = 'No'

n = int(input())
for i in range(n):
	In = int(input())
    
	a1 = ['' if a1[j] == In else a1[j] for j in range(3)]
	a2 = ['' if a2[j] == In else a2[j] for j in range(3)]
	a3 = ['' if a3[j] == In else a3[j] for j in range(3)]
    
# tate
for i in range(2):
	if a1[i] == '' and a2[i] == '' and a3[i] == '':
		result = 'Yes'
		break
# yoko
if a1.count('') == 3:
		result = 'Yes'
if a2.count('') == 3:
		result = 'Yes'
if a3.count('') == 3:
		result = 'Yes'

# naname
if a1[0] == '' and a2[1] == '' and a3[2] == '':
		result = 'Yes'
    
if a1[2] == '' and a2[1] == '' and a3[3] == '':
		result = 'Yes'
print(result)

Submission status: Runtime Error

Solution code:
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = []
for i in range(N):
	b.append(int(input()))
	
yoko = A
tate = [[], [], []]
for row in A:
	for i in range(3):
		tate[i].append(row[i])
naname = [[A[0][0], A[1][1], A[2][2]], [A[0][3], A[1][1], A[2][0]]]

all = yoko + tate + naname

y = 0
chk = 0
for kumi in all:
	for k in kumi:
		if k in b:
			chk += 1
		else:
			continue
	if chk == 3:
		print("Yes")
		y = 1
		break
	else:
		chk = 0
		
if y == 0:
	print("No")

Submission status: Runtime Error

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

for i in range (N):
    for j in range(len(A[0])):
        if (B[i] in A[j]):
            #print(type(B[i]),B[i],A[j])
            A[j][A[j].index(B[i])]=0
check=0
if((A[0][0]+A[1][1]+A[2][2]==0) or (A[2][0]+A[1][1]+A[0][2]==0) ):
    print('Yes');check=1
else:    
    for j in range(len(A[0])): 
        if( (A[j][0]+A[j][1]+A[j][2]==0) or (A[0][j]+A[1][j]+A[2][j]==0)    ):    
            print('Yes');check=1
            break;
    if(check==0):
        print('No')

Submission status: Runtime Error

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

ans = [int(input()) for _ in range(9)]


L_tate = list(zip(*L_yoko))

L_naname = []
L_naname.append([L_yoko[0][0],L_yoko[1][1],L_yoko[2][2]])
L_naname.append([L_yoko[0][2],L_yoko[1][1],L_yoko[2][0]])

a = int(0)
for x in L_tate:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break
    else:
        continue

for y in L_yoko:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break
    else:
        continue

for z in L_naname:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break
    else:
        continue


if a == 0:
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
import itertools

[a,b,c] = [int(x) for x in input().split()]
[d,e,f] = [int(x) for x in input().split()]
[g,h,i] = [int(x) for x in input().split()]
N = int(input())
num_list = []
for i in N:
  n = int(input())
  num_list.append(n)
set_list = [{a,b,c},{d,e,f},{g,h,i},{a,d,g},{b,e,h},{c,f,i},{a,e,i}]
the_set = set(num_list) & set([a,b,c,d,e,f,g,h,i])
v = itertools.permutations(the_set,3)
for i in f:
  if i in set_list:
    print('Yes')
    break

Submission status: Runtime Error

Solution code:
a = input().split()
a += input().split()
a += input().split()
n = int(input())
b = set([(int)(input()) for i in range(n)])

bingo = False
if set([a[0], a[1], a[2]).issubset(b):
	bingo = True
if set([a[3], a[4], a[5]).issubset(b):
	bingo = True
if set([a[6], a[7], a[8]).issubset(b):
	bingo = True
if set([a[0], a[3], a[6]).issubset(b):
	bingo = True
if set([a[1], a[4], a[7]).issubset(b):
	bingo = True
if set([a[2], a[5], a[8]).issubset(b):
	bingo = True
if set([a[0], a[4], a[8]).issubset(b):
	bingo = True
if set([a[2], a[4], a[6]).issubset(b):
	bingo = True
print(bingo)

Submission status: Runtime Error

Solution code:
A = [list(map(int,input().split(" "))) for i in range(3)]
N = int(input())
b = list(map(int(input())))
import numpy as np
A = np.array(A)
l = []
for i in range(N):
  if b[i] in A:
    l.append(tuple(nd[0] for nd in np.where(A == b[i])))
if (0, 0) in l and (1, 0) in l and (2, 0) in l:
  print("Yes")
elif (0, 0) in l and (1, 1) in l and (2, 2) in l:
  print("Yes")
elif (0, 1) in l and (1, 1) in l and (2, 1) in l:
  print("Yes")
elif (0, 2) in l and (1, 1) in l and (2, 0) in l:
  print("Yes")
elif (0, 2) in l and (1, 2) in l and (2, 2) in l:
  print("Yes")
elif (0, 0) in l and (0, 1) in l and (0, 2) in l:
  print("Yes")
elif (1, 0) in l and (1, 1) in l and (1, 2) in l:
  print("Yes")
elif (2, 0) in l and (2, 1) in l and (2, 2) in l:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import numpy as np

grid = []
for i in range(3):
    array = list(map(int,input().strip().split()))
    grid.append(array)
    
grid = np.array(grid)

N = int(input().split())
s = [int(input()) for i in range(N)]

for i in s:
    b = np.where(grid==i,0,grid)
    
if grid[0][0]==0 & grid[0][1]==0 & grid[0][2]==0:
    han = "Yes"
elif grid[1][0]==0 & grid[1][1]==0 & grid[1][2]==0:
    han = "Yes"
elif grid[2][0]==0 & grid[2][1]==0 & grid[2][2]==0:
    han = "Yes"
elif grid[0][0]==0 & grid[1][0]==0 & grid[2][0]==0:
    han = "Yes"
elif grid[0][1]==0 & grid[1][1]==0 & grid[2][1]==0:
    han = "Yes"
elif grid[0][2]==0 & grid[1][2]==0 & grid[2][2]==0:
    han = "Yes"
elif grid[0][0]==0 & grid[1][1]==0 & grid[2][2]==0:
    han = "Yes"
elif grid[0][2]==0 & grid[1][1]==0 & grid[2][0]==0:
    han = "Yes"
else:
    han = "No"
print(han)

Submission status: Runtime Error

Solution code:
A11, A12, A13=list(map(int,input().split()))
A21, A22, A23=list(map(int,input().split()))
A31, A32, A33=list(map(int,input().split()))
N=int(input())
b=[input() for i in range(N)]
if A11, A12, A13 in b:
    print('Yes')
elif A21, A22, A23 in b:
    print('Yes')
elif A31, A32, A33 in b:
    print('Yes')
elif A11, A21, A31 in b:
    print('Yes')
elif A12, A22, A32 in b:
    print('Yes')
elif A13, A23, A33 in b:
    print('Yes')
elif A11, A22, A33 in b:
    print('Yes')
elif A13, A22, A31 in b:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
mport sys
s = sys.stdin.readlines()
A1_1,A1_2,A1_3= map(int, s[0].split())
A2_1,A2_2,A2_3= map(int, s[1].split())
A3_1,A3_2,A3_3= map(int, s[2].split())
N=map(int, s[3].split())
B=[]
for e in s[4:N + 4]:
    B.append(e)
a=str('yes')
b=str('no')
if A1_1 in B and A1_2 in B and A1_3 in B:
     print(a)
elif A2_1 in B and A2_2 in B and A2_3 in B:
    print(a)
elif A3_1 in B and A3_2 in B and A3_3 in B:
     print(a)
elif A1_1 in B and A2_1 in B and A3_1 in B:
    print(a)
elif A1_2 in B and A2_2 in B and A3_2 in B:
    print(a)
elif A1_3 in B and A2_3 in B and A3_3 in B:
    print(a)
elif A1_1 in B and A2_2 in B and A3_3 in B:
     print(a)
elif A1_3 in B and A2_2 in B and A3_1 in B:
    print(a)
else:
    print(b)

Submission status: Runtime Error

Solution code:
a,b,c=int(input()).split()
d,e,f=int(input()).split()
g,h,i=int(input()).split()

x=[[a,b,c],[d,e,f],[g,h,i]]
while True:
    b_i=int(input())
    if b_i in x:
        x[b_i]=0
if x[:,0]==0:
    print(“Yes”)
if x[:,1]==0:
    print(“Yes”)
if x[:,2]==0:
    print(“Yes”)
if x[0,:]==0:
    print(“Yes”)
if x[1,:]==0:
    print(“Yes”)
if x[2:,]==0:
    print(“Yes”)
if x[0,0] and x[1,1] and x[2,2]==0:
    print(“Yes”)
if x[0,2] and x[1,1] and x[2,0]==0:
    print(“Yes”)
else:
    print(“No”)

Submission status: Runtime Error

Solution code:
a=list(map(int,input().split()))
b=len(a)
c=[a]
w=0
for i in range(b-1):
    c.append(list(map(int,input().split())))
N=int(input())
d=[]
for y in range(N):
    d.append(int(input()))
for n in d:
    for p in c:
        for j in p:
            if n in j:
                j=0
for t in c:
    for h in t:
        if c.count(0)==b:
            o=1
            break
    else:
        continue
    break
for v in range(b):
    w=0
    for k in c:
        if k[v]==0:
            w+=1
        if w==b:
            o=1
w=0
for ji in range(b):
    if c[ji][ji]==0:
        w+=1
    if w==b:
        o=1
w=0
for ji2 in range(b):
    if c[ji2][b-ji2]==0:
        w+=1
    if w==b:
        o=1
if o==1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import itertools

[a,b,c] = [int(x) for x in input().split()]
[d,e,f] = [int(x) for x in input().split()]
[g,h,i] = [int(x) for x in input().split()]
N = int(input())
num_list = []
for i in N:
  n = int(input())
  num_list.append(n)
set_list = [{a,b,c},{d,e,f},{g,h,i},{a,d,g},{b,e,h},{c,f,i},{a,e,i}]
the_set = set(num_list) & set([a,b,c,d,e,f,g])
v = itertools.permutations(the_set,3)
for i in f:
  if i in set_list:
    print('Yes')
    break

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
a.extend(list(map(int,input().split())))
a.extend(list(map(int,input().split())))
b = [0] * 10
while True:
    flag = 0
    n = input()
    if n == '':
        break
    else:
        n = int(n)
    if n in a:
        k = a.index(n)
        b[k] = 1
        if b[4] == 1 and b[8 - k] == 1 and k != 4:
            print('Yes')
            flag = 1
            break
if flag != 1:
    print('No')

Submission status: Runtime Error

Solution code:
import numpy as np

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

N = int(input())
b = np.zeros(N, dtype=np.int)
for i in range(N):
    b[i] = int(input())
# print(A)
# print(b)
# T = A[A in b]
T = np.isin(A,b)
# print(T)
ans=[0,0,0,0]
ans[0]=T.all(axis=0).all()
ans[1]=T.all(axis=1).all()
ans[2]=np.diag(T).all()
ans[3]=np.diag(T[:,[2,1,0]]).all()
# print(ans)
if any(ans):
    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())
b = []
for i in range(7):
    b.append(int(input()))
flag = False
for i in range(3):
    #for j in range(3):
    if a[0 + i][0] in b and a[0 + i][1] in b and a[0 + i][2] in b:
        #print('Yes')
        #quit()
        flag = True
for i in range(3):
    #for j in range(3):
    if a[0][0 + i] in b and a[1][0 + i] in b and a[2][0 + i] in b:
        #print('Yes')
        #quit()
        flag = True
        
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    #print('Yes')
    #quit()
    flag = True
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    #print('Yes')
    #quit()
    flag = True
#print('No')
if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import itertools

[a,b,c] = [int(x) for x in input().split()]
[d,e,f] = [int(x) for x in input().split()]
[g,h,i] = [int(x) for x in input().split()]
N = int(input())
num_list = []
for i in N:
  n = int(input())
  num_list.append(n)
set_list = [{a,b,c},{d,e,f},{g,h,i},{a,d,g},{b,e,h},{c,f,i},{a,e,i}]
the_set = set(N) & set([a,b,c,d,e,f,g])
v = itertools.permutations(the_set,3)
for i in f:
  if i in set_list:
    print('Yes')
    break

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

lines = sys.stdin.readlines()
bingo_card = np.zeros([3,3])
for i, l in enumerate(input()):
    if i <= 2:
        bingo_card[i] = [int(num) for num in l.split()]
    else:
        bingo_card[bingo_card == int(l)] = None
        
check_arr = np.isnan(bingo_card)
if check_arr[0].sum() == 3 or check_arr[1].sum() == 3 or check_arr[2].sum() == 3:
    print('Yes')
elif check_arr[:, 0].sum() == 3 or check_arr[:, 1].sum() == 3 or check_arr[:, 2].sum() == 3:
    print('Yes')
elif check_arr[0,0] and check_arr[1,1] and check_arr[2,2]:
    print('Yes')
elif check_arr[0,2] and check_arr[1,1] and check_arr[2,0]:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
first_line = input().split()
second_line = input().split()
third_line = input().split()
 
first_line = [int(i) for i in first_line]
second_line = [int(i) for i in second_line]
third_line = [int(i) for i in third_line]

N = input()
N = int(N)



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



for i in range(3):
    arr[0][i]= first_line[i]
for i in range(3):
    arr[0][i]= second_line[i]
for i in range(3):
    arr[0][i]= third_line[i]

carr = [[False]*3]*3
for b in B:
    for i in range(3):
        for j  in range(3):
            if b == arr[i][j]:
                carr[i][j] = True


def yoko(carr):
    for i in range(3):
        for j in range(3):
            if carr[i][j] != True:
                break
        return  True
    
    return False


def tate(carr):
    for i in range(3):
        for j in range(3):
            if carr[j][i] != True:
                break
        return  True
    
    return False

def naname (carr):
    for i in range(3):
        if carr[i] != True:
            for j in range(3):
                if carr[3-j-1] != True:
                    return False
            return True    
    return True


def checker(carr):
    if not tate  and not yoko and not naname:
        return 'No'
    else:
        return 'Yes' 



print(checker(carr))

Submission status: Runtime Error

Solution code:
A11, A12, A13=list(map(int,input().split()))
A21, A22, A23=list(map(int,input().split()))
A31, A32, A33=list(map(int,input().split()))
N=int(input())
b=[input() for i in range(N)]
if A11 in b and A12 in b and A13 in b:
    print('Yes')
elif A21 in b and A22 in b and A23 in b:
    print('Yes')
elif A31 in b and A32 in b and A33 in b:
    print('Yes')
elif A11 in b and A21 in b and A31 in b:
    print('Yes')
elif A12 in b and A22 in b and A32 in b:
    print('Yes')
elif A13 in b and A23 in b and A33 in b:
    print('Yes')
elif in b A11 and A22 in b and A33 in b:
    print('Yes')
elif A13 in b and A22 in b and A31 in b:
    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())
b = []
for i in range(7):
    b.append(int(input()))

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

for i in range(3):
    #for j in range(3):
    if a[0][0 + i] in b and a[1][0 + i] in b and a[2][0 + i] 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[2][0] in b and a[1][1] in b and a[0][2] in b:
    print('Yes')
    quit()
print('No')

Submission status: Runtime Error

Solution code:
from sys import stdin,exit
import  numpy as np
A = [stdin.readline().rstrip().split() for _ in range(3)]
A=sum(A,[])
n = int(stdin.readline().rstrip())
B= [stdin.readline().rstrip().split() for _ in range(n)]
B=sum(B,[])
if len(B)<=2:
    print("No")
    sys.exit()
for i in range(len(B)):
    try:
        A[A.index(B[i])]=0
    except:
        continue    
if A[1]+A[2]+A[0]==0 or A[0]+A[3]+A[6]==0 or A[2]+A[4]+A[6]==0 or A[3]+A[4]+A[5]==0 or A[1]+A[4]+A[7]==0 or A[0]+A[4]+A[8]==0 or A[6]+A[7]+A[8]==0 or A[2]+A[5]+A[8]==0:
    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()))
blis = [[1,2,3],[4,5,6],[7,8,9],[1,4,7],[2,5,8],[3,6,9],[1,5,9],[3,5,7]]
             
ans = []
for x in range(n):
    for i in range(3):
        for j in range(3):
             if a[i,j]==b[x]:
                 if i == 1:
                     ans,append(j)
                 elif i == 2:
                     ans.append(j+3)
                 elif i == 3:
                     ans.append(j+6)
w=0
for i in range(8):
    z = 0
    for j in range(3):
        if blis[i,j] in ans:
             z += 1
    if z ==3:
        print("Yes")
        break
    else:
        w += 1
if w == 8:
    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):
  print(i)
  b[i]=int(input())
C1=any([i == A1[0] for i in b])
C2=any([i == A1[1] for i in b])
C3=any([i == A1[2] for i in b])
C4=any([i == A2[0] for i in b])
C5=any([i == A2[1] for i in b])
C6=any([i == A2[2] for i in b])
C7=any([i == A3[0] for i in b])
C8=any([i == A3[1] for i in b])
C9=any([i == A3[2] for i in b])

if(any(all(C1,C2,C3),all(C4,C5,C6),all(C7,C8,C9),all(C1,C4,C7),all(C2,C5,C8),all(C3,C6,C9),all(C1,C5,C9),all(C3,C5,C7)):
   print("Yes")
else:
   print("No")

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())
d, e, f = map(int, input().split())
g, h, i = map(int, input().split())
num_count = int(input())
number_list = [0] * num_count
for i in range(num_count):
    number_list[i] = int(input())

bingo_map = [[a, b, c], [d, e, f], [g, h, i]]
bingo_answer = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

def bingo(bingo_map, number_list):
    for number in number_list:
        for i, bingo_row in enumerate(bingo_map):
            if number in bingo_row:
                for j, bingo_number in enumerate(bingo_row):
                    if bingo_number == number:
                        bingo_answer[i][j] = 1


def check_bingo():
    return (all(bingo_answer[0]) or all(bingo_answer[1]) or all(bingo_answer[2]) or
    all(bingo_answer[0][0], bingo_answer[1][0], bingo_answer[2][0]) or
    all(bingo_answer[0][1], bingo_answer[1][1], bingo_answer[2][1]) or
    all(bingo_answer[0][2], bingo_answer[1][2], bingo_answer[2][2]) or
    all(bingo_answer[0][0], bingo_answer[1][1], bingo_answer[2][2]) or
    all(bingo_answer[2][0], bingo_answer[1][1], bingo_answer[0][2]))

bingo(bingo_map, number_list)

if (check_bingo()):
    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())
b = []
for i in range(7):
    b.append(int(input()))
for i in range(3):
    #for j in range(3):
    if a[0 + i][0] in b and a[0 + i][1] in b and a[0 + i][2] in b:
        print('Yes')
        quit()

for i in range(3):
    #for j in range(3):
    if a[0][0 + i] in b and a[1][0 + i] in b and a[2][0 + i] 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[2][0] in b and a[1][1] in b and a[0][2] in b:
    print('Yes')
    quit()
print('No')

Submission status: Runtime Error

Solution code:
A11, A12, A13=list1(map(int,input().split()))
A21, A22, A23=list2(map(int,input().split()))
A31, A32, A33=list3(map(int,input().split()))
N=int(input())
b=[input() for i in range(N)]
if A11 and A12 and A13 in b:
    print('Yes')
elif A21 and A22 and A23 in b:
    print('Yes')
elif A31 and A32 and A33 in b:
    print('Yes')
elif A11 and A21 and A31 in b:
    print('Yes')
elif A12 and A22 and A32 in b:
    print('Yes')
elif A13 and A23 and A33 in b:
    print('Yes')
elif A11 and A22 and A33 in b:
    print('Yes')
elif A13 and A22 and A31 in b:
    print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
boad1 = map(int, input().aplit())
boad2 = map(int, input().aplit())
boad3 = map(int, input().aplit())
N = int(input())
score = [3][3]
for i in range(N):
    num.append(int(input()))
    for k in range(3):
        if num == boad1[k]:
            score[0].append(k)
    for k in range(3):
        if num == boad2[k]:
            score[1].append(k)
    for k in range(3):
        if num == boad3[k]:
            score[2].append(k)
if N < 3:
    print("No")
if score[0][0] == 1 and score[0][0] and score[0][0]:
    print("Yes")
elif score[1][0] == 1 and score[1][0] and score[1][0]:
    print("Yes")
elif score[2][0] == 1 and score[2][0] and score[2][0]:
    print("Yes")
elif score[0][0] == 1 and score[1][0] and score[2][0]:
    print("Yes")
elif score[0][1] == 1 and score[1][1] and score[2][1]:
    print("Yes")
elif score[0][2] == 1 and score[1][2] and score[2][2]:
    print("Yes")
elif score[0][0] == 1 and score[1][1] and score[2][2]:
    print("Yes")
elif score[0][2] == 1 and score[1][1] and score[2][0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
a.extend(list(map(int,input().split())))
a.extend(list(map(int,input().split())))
b = [0] * 10
while True:
    flag = 0
    n = int(input())
    if n in a:
        k = a.index(n)
        b[k] = 1
        if b[4] == 1 and b[8 - k] == 1 and k != 4:
            print('Yes')
            flag = 1
            break
if flag != 1:
    print('No')

Submission status: Runtime Error

Solution code:
A = [[[] for i in range(3)] for i in range(3)]
for i in range(3):
    for j in range(3):
        number=int(input())
        A[i][j]=number
N = int(input())
counter = 0
while N > 0:
    B = int(input())
    print(B)
    for i in range(3):
        for j in range(3):
            if B == A[i][j]: 
                counter += 1
    N -= 1
if counter > 0:
    print("Yes")
else: 
    print("No")

Submission status: Runtime Error

Solution code:
A = np.array([list(map(int,input().split())),list(map(int,input().split())),list(map(int,input().split()))])
N = int(input())
B = [input() for _  in range(N)]
C = [1000, 1000, 1000]
for z in range(N):
    for x in range(3):
        for y in range(3):
            if B[z] == A[x][y]:
                A[x][y] = 1000
                

if (A[0] == C).all or (A.T[0] == C).all or (A[1] == C).all or (A[2] == C).all or (A.T[1] == C).all or (A.T[2] == C).all
    print('Yes')
elif A[0][1] == A[1][1] == A[2][2] or A[0][2] == A[1][1] == A[2][0]:   
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
A1_1,A1_2,A1_3 = map(int, input().split())
A2_1,A2_2,A2_3 = map(int, input().split())    
A3_1,A3_2,A3_3 = map(int, input().split())
N = int(input())
B = []
for _ in range(N):
    S.append(input())

a=str('yes')
b=str('no')
if A1_1 in B and A1_2 in B and A1_3 in B:
     print(a)
elif A2_1 in B and A2_2 in B and A2_3 in B:
    print(a)
elif A3_1 in B and A3_2 in B and A3_3 in B:
     print(a)
elif A1_1 in B and A2_1 in B and A3_1 in B:
    print(a)
elif A1_2 in B and A2_2 in B and A3_2 in B:
    print(a)
elif A1_3 in B and A2_3 in B and A3_3 in B:
    print(a)
elif A1_1 in B and A2_2 in B and A3_3 in B:
     print(a)
elif A1_3 in B and A2_2 in B and A3_1 in B:
    print(a)
else:
    print(b)

Submission status: Runtime Error

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

ans = []
for i in range(9):
     x = int(input())
     ans.append(x)


L_tate = list(zip(*L_yoko))

L_naname = []
L_naname.append([L_yoko[0][0],L_yoko[1][1],L_yoko[2][2]])
L_naname.append([L_yoko[0][2],L_yoko[1][1],L_yoko[2][0]])

a = int(0)
for z in L_tate:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

for z in L_yoko:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break

for z in L_naname:
    if z[0] in ans and z[1] in ans and z[2] in ans:
         a = 1
         break


if a == 1:
    print("Yes")
else:
    print("No")