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.

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A1 = [int(x) for x in input().split()]
    A2 = [int(x) for x in input().split()]
    A3 = [int(x) for x in input().split()]
    N = int(input())
    A = set([int(input()) for _ in range(N)])
    f = False
    if A1[0] in A and A1[1] in A and A1[2] in A:
        print("Yes")
        return
    if A2[0] in A and A2[1] in A and A2[2] in A:
        print("Yes")
        return
    if A3[0] in A and A3[1] in A and A3[2] in A:
        print("Yes")
        return
    if A1[0] in A and A2[0] in A and A3[0] in A:
        print("Yes")
        return
    if A1[1] in A and A2[1] in A and A3[1] in A:
        print("Yes")
        return
    if A1[2] in A and A2[2] in A and A3[2] in A:
        print("Yes")
        return
    if A1[0] in A and A2[1] in A and A3[2] in A:
        print("Yes")
        return
    if A1[2] in A and A2[1] in A and A3[0] in A:
        print("Yes")
        return
    print("No")

    
    
    



if __name__ == '__main__':
    main()

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

c = [[0]*3 for _ in range(3)]
for b in B:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                c[i][j] = 1

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

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

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

is_bingo = False
for i in range(3):
    if sum([a[i][j] for j in range(3)]) == 0:
        is_bingo = True
        break
    if sum([a[j][i] for j in range(3)]) == 0:
        is_bingo = True
        break

if sum([a[j][j] for j in range(3)]) == 0:
    is_bingo = True
if sum([a[j][2 - j] for j in range(3)]) == 0:
    is_bingo = True

ans = 'Yes' if is_bingo else 'No'
print(ans)

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

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



print('No')

Solution (Python):



import sys
readline = sys.stdin.readline
read = sys.stdin.read








    
a = [[int(i) for i in readline().split()] for _ in range(3)]
n,*b = [int(i) for i in read().split()]

res = [0]*1000
for i in b:
    res[i] = 1

ok = 0
for i in range(3):
    if res[a[i][0]] == res[a[i][1]] == res[a[i][2]] == 1:
        ok = 1

for i in range(3):
    if res[a[0][i]] == res[a[1][i]] == res[a[2][i]] == 1:
        ok = 1

if res[a[0][0]] == res[a[1][1]] == res[a[2][2]] == 1:
    ok = 1

if res[a[0][2]] == res[a[1][1]] == res[a[2][0]] == 1:
    ok = 1

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

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

def check() :
  
  for x in range(3) :
    if all(A[y][x] in b for y in range(3)) :
      return True
      
  
  for y in range(3) :
    if all(A[y][x] in b for x in range(3)) :
      return True
      
  
  if all(A[i][i] in b for i in range(3)) : return True
  if all(A[2-i][i] in b for i in range(3)) : return True
    
  return False
  
if check() :
  print('Yes')
else :
  print('No')

Solution (Python):
a = list(map(int,input().split()))
a += list(map(int,input().split()))
a += list(map(int,input().split()))
b = [0 for _ in range(9)]
n = int(input())
for _ in range(n):
  tmp = int(input())
  for i in range(9):
    if tmp == a[i]:
      b[i] = 1
if b[0] == b[1] == b[2] == 1:
  print('Yes')
  exit()
if b[3] == b[4] == b[5] == 1:
  print('Yes')
  exit()
if b[6] == b[7] == b[8] == 1:
  print('Yes')
  exit()
if b[0] == b[3] == b[6] == 1:
  print('Yes')
  exit()
if b[1] == b[4] == b[7] == 1:
  print('Yes')
  exit()
if b[2] == b[5] == b[8] == 1:
  print('Yes')
  exit()
if b[0] == b[4] == b[8] == 1:
  print('Yes')
  exit()
if b[2] == b[4] == b[6] == 1:
  print('Yes')
  exit()
print('No')

Solution (Python):
A = [[int(a) for a in input().split()] for _ in range(3)]
B = [[0] * 3 for _ in range(3)]
N = int(input())
for _ in range(N):
    a = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == a:
                B[i][j] = 1

for i in range(3):
    if sum([B[i][j] for j in range(3)]) == 3:
        print("Yes")
        exit()

for j in range(3):
    if sum([B[i][j] for i in range(3)]) == 3:
        print("Yes")
        exit()

if sum([B[i][i] for i in range(3)]) == 3:
    print("Yes")
    exit()

if sum([B[i][2-i] for i in range(3)]) == 3:
    print("Yes")
    exit()

print("No")

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

N = input()
for _ in range(N):
  b = input()
  for y in range(3):
    for x in range(3):
      if A[y][x]==b:
        A[y][x] = 0

ans = "No"
for y in range(3):
  if A[y]==[0, 0, 0]:
    ans = "Yes"
for x in range(3):
  if [A[y][x] for y in range(3)]==[0, 0, 0]:
    ans = "Yes"
if [A[0][0], A[1][1], A[2][2]]==[0, 0, 0]:
  ans = "Yes"
if [A[2][0], A[1][1], A[0][2]]==[0, 0, 0]:
  ans = "Yes"
print ans

Solution (Python):

import sys
INF = float("inf")


def yes():
    print("Yes")  


def no():
    print("No")  


def solve(A: "List[List[int]]", N: int, b: "List[int]"):

    flag = False
    
    for i in range(3):
        if A[i][0] in b and A[i][1] in b and A[i][2] in b:
            flag = True
            break
    
    for i in range(3):
        if A[0][i] in b and A[1][i] in b and A[2][i] in b:
            flag = True
            break
    
    if A[0][0] in b and A[1][1] in b and A[2][2] in b:
        flag = True
    if A[0][2] in b and A[1][1] in b and A[2][0] in b:
        flag = True

    if flag:
        yes()
    else:
        no()

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)]
         for _ in range(3)]  
    N = int(next(tokens))  
    b = [int(next(tokens)) for _ in range(N)]  
    solve(A, N, b)


if __name__ == '__main__':
    main()

Solution (Python):
def main() -> None:
    board = [[int(x) for x in input().split()] for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]
    bingo = [[False] * 3 for _ in range(3)]
    for b in B:
        for i in range(3):
            for j in range(3):
                if b == board[i][j]:
                    bingo[i][j] = True
    flag = False
    for i in range(3):
        if all(bingo[i][j] for j in range(3)):
            flag = True
        if all(bingo[j][i] for j in range(3)):
            flag = True
    if all(bingo[i][i] for i in range(3)):
        flag = True
    if all(bingo[i][2-i] for i in range(3)):
        flag = True
    print("Yes" if flag else "No")



if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



A = [LI() for _ in range(3)]
N = I()
b = LIR(N,1)

c = [[False]*3 for _ 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
for i in range(3):
    if c[i][0] == c[i][1] == c[i][2] == True:
        print('Yes')
        exit()
for i in range(3):
    if c[0][i] == c[1][i] == c[2][i] == True:
        print('Yes')
        exit()
if c[0][0] == c[1][1] == c[2][2] == True:
    print('Yes')
    exit()
if c[0][2] == c[1][1] == c[2][0] == True:
    print('Yes')
    exit()

print('No')

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

used = [[False] * 3 for i in range(3)] 
for num in range(n):
    for i in range(3):
        for j in range(3):
            if a[i][j] == b[num]:
                used[i][j] = True

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

Solution (Python):


from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

A = [map(int, raw_input().split()) for i in range(3)]
N = input()
for i in range(N):
    b = input()
    for j in range(3):
        for k in range(3):
            if b == A[j][k]:
                A[j][k] = 0
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2] == 0:
        print "Yes"
        exit()
    if A[0][i] == A[1][i] == A[2][i] == 0:
        print "Yes"
        exit()
if A[0][0] == A[1][1] == A[2][2] == 0:
    print "Yes"
    exit()
if A[0][2] == A[1][1] == A[2][0] == 0:
    print "Yes"
    exit()
print "No"

Solution (Python):
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for h in range(3):
        for w in range(3):
            if A[h][w]==b:
                A[h][w]=0
ans = "No"
for h in range(3):
    cnt = 0
    for w in range(3):
        if A[h][w]==0:cnt+=1
    if cnt==3:ans="Yes"
for w in range(3):
    cnt = 0
    for h in range(3):
        if A[h][w]==0:cnt+=1
    if cnt==3:ans="Yes"
if A[0][0]+A[1][1]+A[2][2]==0:ans="Yes"
if A[2][0]+A[1][1]+A[0][2]==0:ans="Yes"
print(ans)

Solution (Python):
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)):
        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:
    print("No")

Solution (Python):
a = [list(map(int, input().split())) for _ in range(3)]
d = [[0] * 3 for _ 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:
                d[j][k] = 1
for i in range(3):
    if sum(d[i]) == 3:
        print('Yes')
        exit(0)
for i in range(3):
    res = 0
    for j in range(3):
        res += d[j][i]
    if res == 3:
        print('Yes')
        exit(0)
res = 0
for i in range(3):
    res += d[i][i]
if res == 3:
    print('Yes')
    exit(0)
res = 0
for i in range(3):
    res += d[i][2 - i]
if res == 3:
    print('Yes')
    exit(0)
print('No')

Solution (Python):
a=[list(map(int,input().split()))for _ in range(3)]
for i in range(int(input())):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a = LIR(3)
    n = I()
    b = IR(n)
    f = defaultdict(lambda : 0)
    for i in b:
        f[i] = 1
    for i in range(3):
        m = 0
        for j in range(3):
            m += f[a[i][j]]
        if m == 3:
            print("Yes")
            return
        m = 0
        for j in range(3):
            m += f[a[j][i]]
        if m == 3:
            print("Yes")
            return
    m = 0
    for j in range(3):
        m += f[a[j][j]]
    if m == 3:
        print("Yes")
        return
    m = 0
    for j in range(3):
        m += f[a[-1-j][j]]
    if m == 3:
        print("Yes")
        return
    print("No")
    return


if __name__ == "__main__":
    solve()