Problem:
 Score : 200 points    Problem Statement You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1 . Also, the given images are binary images, and the color of each pixel is either white or black.  In the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel. The image A is given as N strings A_1,...,A_N . The j -th character in the string A_i corresponds to the pixel at the i -th row and j -th column of the image A  (1≦i,j≦N) . Similarly, the template image B is given as M strings B_1,...,B_M . The j -th character in the string B_i corresponds to the pixel at the i -th row and j -th column of the template image B  (1≦i,j≦M) .  Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.      Constraints  1≦M≦N≦50   A_i is a string of length N consisting of # and . .  B_i is a string of length M consisting of # and . .         Input The input is given from Standard Input in the following format:  N  M  A_1  A_2  :  A_N  B_1  B_2  :  B_M       Output Print Yes if the template image B is contained in the image A . Print No otherwise.        Sample Input 1 3 2
#.#
.#.
#.#
#.
.#      Sample Output 1 Yes  The template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A . Thus, the output should be Yes .       Sample Input 2 4 1
....
....
....
....
#      Sample Output 2 No  The template image B , composed of a black pixel, is not contained in the image A composed of white pixels.

Solution (Python):
import numpy as np

n, m = map(int, input().split())
a = np.array([list(input()) for _ in range(n)])
b = np.array([list(input()) for _ in range(m)])

ans = 'No'
for i in range(n-m+1):
    for j in range(n-m+1):
        if (a[i:m+i, j:m+j] == b).all():
            ans = 'Yes'
print(ans)

Solution (Python):
n, m = map(int,input().split())
A = [[] for _ in range(n)]
for i in range(n):
    A[i] = input()
B = [[] for _ in range(m)]
for i in range(m):
    B[i] = input()
    
flag = False
for tate_begin in range(n-m+1):
    for yoko_begin in range(len(A[0])-len(B[0])+1):
        for check in range(m):
            a_yoko = A[tate_begin+check][yoko_begin:yoko_begin+len(B[0])]
            if a_yoko != B[check]:
                break
        else:
            flag = True
            print('Yes')
    if flag:
        break
else:
    print('No')

Solution (Python):
n, m = map(int, input().split())
A = []
B = []
for i in range(n):
    A.append(input())
for i in range(m):
    B.append(input())

ok = 0
for i in range(n - m + 1):
    for j in range(n - m + 1):
        from_n = [l[j:j+m] for l in A[i:i+m]]
        ok += from_n == B
print('Yes' if ok > 0 else 'No')

Solution (Python):


def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N, M = MII()
    A = []
    for _ in range(N):
        A.append(list(input()))

    B = []
    for _ in range(M):
        B.append(list(input()))

    f = True
    for i in range(N-M+1):
        for j in range(N-M+1):
            for k in range(M):
                if A[i+k][j:j+M] != B[k]:
                    f = False
                    break
                f = True
            if f:
                print('Yes')
                return
    
    print('No')

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,M = I()
maze1 = [list(s()) for _ in range(N)]
maze2 = [list(s()) for _ in range(M)]
L = [[-1]*N for _ in range(N)]
def dfs(x,y):
    if x == N or y == N:
        return
    if x-i == M or y-j == M:
        return
    if maze1[x][y] != maze2[x-i][y-j]:
        L[i][j] = 0
        return
    dfs(x+1,y)
    dfs(x,y+1)
for i in range(N-M+1):
    for j in range(N-M+1):
        dfs(i,j)
        if L[i][j] == -1:
            print('Yes')
            exit()
print('No')

Solution (Python):
import numpy as np
N,M = map(int,input().split())
A = np.array([list(input()) for n in range(N)])
B = np.array([list(input()) for m in range(M)])
a = "No"

for i in range(N-M+1):
  for j in range(N-M+1):
    if (A[i:i+M,j:j+M]==B).all():
      a = "Yes"

print(a)

Solution (Python):

N,M=map(int,input().split())
picN=[]
picM=[]

for i in range(N):
    L=list(input())
    picN.append(L)

for i in range(M):
    L=list(input())
    picM.append(L)

K=N-M

for i in range(K+1):
    for j in range(K+1):
        flg=True
        for a in range(M):
            for b in range(M):
                if picN[a+i][b+j]!=picM[a][b]:
                    flg=False
        if flg:
            break
    if flg:
        break

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

Solution (Python):


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

for i in range(M):
    B.append(list(input()))
    
w = len(B[0])
flg = False    
for i in range(N-M+1):
    if flg:
        break
    
    for j in range(len(A[0])-len(B[0])+1):
        if flg:
            break
        cnt = 0
        for k in range(M):
            
            
            
            if A[i+k][j:j+w] == B[k]:
                cnt += 1
        if cnt == M:
            flg = True
            break

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

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

for _ in range(m):
    b.append(list(input()))

d=0
r=0
while d<n-m+1 :
    for r in range(n-m+1):
        flg=0
        for i in range(m):
            for j in range(m):
                s=a[i+d][j+r]
                t=b[i][j]
                if s==t:
                    continue
                else:
                    flg+=1
        
        if flg==0:
            print('Yes')
            exit(0)

    d+=1


print('No')

Solution (Python):
from itertools import product
import numpy as np

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i, j in product(range(N-M+1), repeat=2):
  if np.prod([A[i+k][j:j+M] == B[k] for k in range(M)]):
    print('Yes')
    break
else:
  print('No')

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

for r in range(n-m+1):
    for c in range(n-m+1):
        flg=True
        for i in range(m):
            for j in range(m):
                if a[r+i][c+j] != b[i][j]:
                    flg=False
                    break
            if not flg:
                break
        if flg:
            print('Yes')
            exit()

print('No')

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

for r in range(n-m+1):
    for c in range(n-m+1):
        flg=True
        for i in range(m):
            for j in range(m):
                if a[r+i][c+j] != b[i][j]:
                    flg=False
                    break
            if not flg:
                break
        if flg:
            print('Yes')
            exit()

print('No')

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]

n,m = imap()
a = [[int(elm=="
b = [[int(elm=="
a,b = np.array(a),np.array(b)



flag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        tmp = a[i:i+m, j:j+m]
        if (tmp == b).all(): flag = 1; break

ans = "Yes" if flag else "No"
print(ans)

Solution (Python):
import numpy as np
n,m=map(int,input().split())
a=np.array([list(input())for i in range(n)])
b=np.array([list(input())for i in range(m)])
d=n-m+1
for i in range(d):
 for j in range(d):
  if (a[i:i+m,j:j+m]==b).all():print("Yes");exit()
print("No")

Solution (Python):
n,m = map(int,input().split())
ag = []
for i in range(n):
    ag.append(list(input()))
bg = []
for i in range(m):
    bg.append(list(input()))
for i in range(n-m+1):
    for j in range(n-m+1):
        u = []
        for k in range(m):
            u.append(ag[j+k][i:i+m])
        if u == bg:
            print("Yes")
            exit()
print("No")

Solution (Python):
import numpy as np

N,M = map(int,input().split())
A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])
ans="No"
bl = False
for i in range(N-M+1):
    for j in range(N-M+1):
        if (A[i:i+M,j:j+M] == B).all():
            ans="Yes"
            break

print(ans)

Solution (Python):
n, m = map(int, input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]
na = len(A[0])
nb = len(B[0])
flag = False
for i in range(n-nb+1):
    for j in range(n-m+1):
        cnt = 0
        for a, b in zip(A[i:i+nb], B):
            if a[j:j+m] == b:
                cnt += 1
        if cnt == m:
            flag = True
            break
print('Yes' if flag else 'No')

Solution (Python):
n,m = map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        flag=1
        for k in range(m):
            for l in range(m):
                if b[k][l]!=a[i+k][j+l]:
                    flag=0
                    break
            if not flag: break
        if flag:
            print("Yes")
            break
    if flag: break
if not flag: print("No")

Solution (Python):
N, M = map(int, input().split())
A = []
for _ in range(N):
    Ai = tuple(input())
    A.append(Ai)
A = tuple(A)
B = []
for _ in range(M):
    Bi = tuple(input())
    B.append(Bi)
B = tuple(B)


for i in range(N - M + 1):
    for j in range(N - M + 1):
        contain = True
        for k in range(M):
            if not contain:
                break
            for l in range(M):
                if A[i + k][j + l] != B[k][l]:
                    contain = False
                    break
        if contain:
            print('Yes')
            exit()
print('No')

Solution (Python):
def main():
    n,m = map(int,input().split())
    a,b = [],[]
    for i in range(n):
        a.append(list(input()))
    for j in range(m):
        b.append(list(input()))
    flag = 0
    for i in range((n-m)+1):
        for j in range((n-m)+1):
            counter = 0
            for k in range(m):
                for l in range(m):
                    if a[k+i][l+j] == b[k][l]:
                        counter += 1
            if counter == m**2:
                flag = 1
    print("Yes" if flag else "No")
main()

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

import numpy as np
A = np.array(A)
B = np.array(B)





if N==M:
    if np.all(A==B):
        print('Yes')
    else:
        print('No')
else:
    for i in range(N-M):
        for j in range(N-M):
    
            a = A[i: i+M, j: j+M]
    
    
            if np.all(a == B):
                print('Yes')
                break
        else:
            continue
        break
    else:
        print('No')

Solution (Python):
N,M=map(int,input().split())
A=[[""]*N for i in range(N)]
B=[[""]*M for i in range(M)]
for y in range(N):
  A[y]=list(input())
for y in range(M):
  B[y]=list(input())
exist=False
for ly in range(N):
  for lx in range(N):
    if ly+M-1>=N or lx+M-1>=N:
      continue
    match=True
    for y in range(M):
      for x in range(M):
        if A[ly+y][lx+x]!=B[y][x]:
          match=False
    if match==True:
      exist=True
print("Yes" if exist==True else "No")

Solution (Python):
def f(s):
    if s==".":
        return 1
    else:
        return 0

N,M=map(int,input().split())
A=[]
for _ in range(N):
    A.append(list(map(f,input())))

B=[]
for _ in range(M):
    B.append(list(map(f,input())))

F=False
for i in range(N-M+1):
    for j in range(N-M+1):
        G=True
        for k in range(M):
            G=G and (A[j+k][i:i+M]==B[k])
        F=F|G
    
if F:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
n, m = map(int, input().split())

X = [input() for _ in range(n)]
np_x = np.zeros((n, n), dtype=int)
for i in range(n):
  for j in range(n):
    np_x[i, j] = X[i][j] == '.'
Y = [input() for _ in range(m)]
np_y = np.zeros((m, m), dtype=int)
for i in range(m):
  for j in range(m):
    np_y[i, j] = Y[i][j] == '.'

for i in range(n-m+1):
  for j in range(n-m+1):
    if np.all(np_x[i:i+m, j:j+m] == np_y):
      print('Yes')
      exit()
else:
  print('No')

Solution (Python):
a, b = map(int,input().split())
A = [input() for _ in range(a)]
B = [input() for _ in range(b)]
ans = "No"
for i in range(a-b+1):
    for j in range(a-b+1):
        cnt = 0
        if A[i][j] == B[0][0]:
            for k in range(b):
                for l in range(b):
                    if A[i+k][j+l] == B[k][l]:
                        cnt += 1
                    if cnt == b**2:
                        ans = "Yes"

print(ans)

Solution (Python):
def mtx2vec(mtx):
    tmp = ''
    for s in mtx:
        tmp += s
    return tmp
N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
    A.append(input())
for _ in range(M):
    B.append(input())

b = ''
for s in B:
    b += s
ans = 'No'
for i in range(N-M+1):
    for j in range(N-M+1):
        tmp = ''
        for k in range(M):
            tmp += A[i+k][j:j+M]
        if tmp == b:
            ans =  'Yes'
            break
print(ans)

Solution (Python):
def search():
    for i in range(N - M + 1):
        for j in range(N - M + 1):
            if all(B[k] == A[i + k][j:j + M] for k in range(M)):
                return 'Yes'
    return 'No'


N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
print(search())

Solution (Python):
N, M = map(int, input().split())
A = [list(input()) for i in range(N)]
B = [list(input()) for i in range(M)]
ans = False
for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] == B[k][l]:
                    continue
                flag = False
                break
            if not flag:
                break
        if flag:
            ans = True
            break
    if ans:
        break
if ans:
    print('Yes')
else:
    print('No')

Solution (Python):
class RollingHash2D:
    def __init__(self, s, n, m, b=1007, c=2009, mod=10**9 + 7):
        self.s = s
        self.n = n
        self.m = m
        self.b = b
        self.c = c
        self.mod = mod

        
        self.hash_cs = [[0] * (self.m + 1) for _ in range(self.n + 1)]
        self.b_pow = [1] * (self.n + 1)  
        self.c_pow = [1] * (self.m + 1)  
        for i in range(self.n):
            self.b_pow[i + 1] = (self.b_pow[i] * self.b) % mod
        for i in range(self.m):
            self.c_pow[i + 1] = (self.c_pow[i] * self.c) % mod

        for i in range(self.n):
            for j in range(self.m):
                self.hash_cs[i + 1][j + 1] = \
                    self.hash_cs[i + 1][j] * self.c \
                    + self.hash_cs[i][j + 1] * self.b \
                    - self.hash_cs[i][j] * self.b * self.c \
                    + self.s[i][j]
                self.hash_cs[i + 1][j + 1] %= self.mod

    def calc_rolling_hash(self, il: int, ir: int, jl: int, jr: int) -> int:
        hash_val = \
            self.hash_cs[ir][jr] \
             - self.hash_cs[ir][jl] * self.c_pow[jr-jl] \
             - self.hash_cs[il][jr] * self.b_pow[ir-il] \
             + self.hash_cs[il][jl] * self.b_pow[ir-il] * self.c_pow[jr-jl]
        hash_val %= self.mod
        return hash_val

    def calc_hash(self, t, nt, mt):
        h = 0
        for i in range(nt):
            for j in range(mt):
                h += t[i][j] * self.b_pow[nt - i - 1] * self.c_pow[mt - j - 1]
                h %= self.mod
        return h


n, m = map(int, input().split())
a = [list(map(ord, list(input()))) for _ in range(n)]
b = [list(map(ord, list(input()))) for _ in range(m)]

rh = RollingHash2D(a, n, n)
b_hash = rh.calc_hash(b, m, m)
flag = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if rh.calc_rolling_hash(i, i + m, j, j + m) == b_hash:
            flag = True
            break
    if flag:
        break

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

Solution (Python):
N, M = map(int, input().split())
A = [input() for a in range(N)]
B = [input() for b in range(M)]
ans = False
for h in range(N - M + 1):
    for w in range(N - M + 1):
        if ans == True:
            break
        for m in range(M):
            if A[h + m][w:w + M] == B[m]:
                pass
            else:
                ans = False
                break
            ans = True
if ans == True:
    print('Yes')
else:
    print('No')

Solution (Python):
I = input().split()
N = int(I[0])
M = int(I[1])

A = [["" for i in range(N)] for i in range(N)]
B = [["" for i in range(M)] for i in range(M)]
for i in range(N):
    A[i] = list(input())
for i in range(M):
    B[i] = list(input())







EQ_flag = 0
for i in range(N+M+1):
    for j in range(N+M+1):
        if ( B == [ A_i[i:i+M] for A_i in A[j:j+M] ] ):
            EQ_flag = 1
            break

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

Solution (Python):


LI = lambda: list(map(int, input().split()))


N, M = LI()
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]


def solve():
    n = N - M + 1
    b = "".join(B)
    for i in range(n):
        for j in range(n):
            a = ""
            for k in range(M):
                a += A[i + k][j : j + M]
            if a == b:
                return "Yes"
    return "No"


def main():
    ans = solve()
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n, m = map(int, input().split())

A = [input() for _ in range(n)]
B = [input() for _ in range(m)]

def issubset(l, u, r, d):
    for i, y in enumerate(range(u, d)):
        for j, x in enumerate(range(l, r)):
            res = A[y][x] == B[i][j]
            if not res:
                return False
    return True

if n == m:
    if issubset(0, 0, n, n):
        print("Yes")
    else:
        print("No")
    exit()

for y in range(n - m):
    for x in range(n - m):
        if issubset(x, y, x+m, y+m):
            print("Yes")
            exit()

print("No")

Solution (Python):
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
s = 0
cnt = 0

for i in range(n-m+1):
    for j in range(n-m+1):
        for x in range(m):
            for y in range(m):
                if a[i+x][j+y] == b[x][y]:
                    s += 1
        if s == m ** 2:
            cnt += 1
        else:
            s = 0
if cnt > 0:
    print('Yes')
else:
    print('No')

Solution (Python):
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
    tmp = input()
    a.append(tmp)
    
for i in range(m):
    tmp = input()
    b.append(tmp)
    
ans = False
for w in range(0 , n-m+1):
    for h in range(0,n-m+1):
        if ans == True:
            break
        flag = True
        for i in range(m):
            if a[h+i][w:w+m] == b[i]:
                pass
            else:
                flag = False
                break
        if flag == True:
            ans = True
if ans:
    print('Yes')
else:
    print('No')

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

for i in range(N - M + 1):
    for j in range(N - M + 1):
        
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i + k][j + l] == B[k][l]:
                    pass
                else:
                    flag = False

        if flag:
            break

    if flag:
        break

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

Solution (Python):
from itertools import product

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i, j in product(range(n - m + 1), repeat=2):
    if all(a[i + k][j:j + m] == b[k] for k in range(m)):
        print('Yes')
        break
else:
    print('No')

Solution (Python):
n,m=map(int,input().split())
s=[input() for i in range(n)]
t=[input() for i in range(m)]

z=0
c=0

for i in range(n-m+1):
    for j in range(n-m+1): 
        
        for x in range(m):
            for y in range(m):
                if s[i+x][j+y]==t[x][y]:
                    z+=1
        if z==m**2:
            c+=1
        else:
            z=0
if c>0:
    print('Yes')
else:
    print('No')

Solution (Python):
n,m = map(int,input().split())
a = [list(input()) for i in range(n)]
b = [list(input()) for i in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if a[i+k][j:j+m] != b[k]:
                break
        else:
            print('Yes')
            exit()
print('No')

Solution (Python):
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = "".join([input() for i in range(m)])
ans = "No"
for i in range(n-m+1):
    for j in range(n-m+1):
        s = ""
        for k in range(m):
            s+=a[i+k][j:j+m]
        if s==b:
            ans = "Yes"
print(ans)

Solution (Python):
def matching(A, B, N, M) :
  if N == M : 
    for j in range(N) : 
      match = 0
      if A[j] != B[j] :
        break
      match += 1
    if match == M : 
      return True
    else :
      return False
  for i in range(N - M) : 
    for j in range(N - M) :
      match = 0
      for m in range(M) :
        if A[j + m][i : M + i] != B[m] :
          break
        match += 1
      if match == M : 
      	return True
  return False
      
          
N, M = tuple(map(int, input().split()))
A = list()
B = list()

for i in range(N) :
  A.append(input())
  
for i in range(M) :
  B.append(input())
  
if matching(A, B, N, M) :
  print('Yes')
else : 
  print('No')

Solution (Python):
N,M=list(map(int,input().split()))
l=[list(input()) for i in range(N)]
mini=[list(input()) for i in range(M)]
mini="".join(sum(mini,[]))
for i in range(N-M+1):
   for j in range(N-M+1):
      let=""
      for k in range(i,M+i):
         let+="".join(l[k][j:j+M])
      if mini == let:
         print("Yes")
         exit()
print("No")

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

def comp(x,y):
    for i in range(M):
        for j in range(M):
            if A[x+i][y+j] != B[i][j]:
                return False
    return True
flag = False
for i in range(N-M+1):
    for j in range(N-M+1):
        if comp(i,j):
            flag = True
            break
if flag:
    print('Yes')
else:
    print('No')

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

def comp(i, j):
    for x in range(m):
        for y in range(m):
            if a[i+x][j+y] != b[x][y]:
                return False
    return True

ans = 'No'
for i in range(n-m+1):
    for j in range(n-m+1):
        if comp(i, j):
            ans = 'Yes'
print(ans)

Solution (Python):
n,m = map(int, input().split())

A = [input() for i in range(n)]
B = [input() for j in range(m)]

for i in range(n-m+1):
  for j in range(n-m+1):
    if A[i][j:j+m] == B[0]:
      if all(A[i+k][j:j+m] == B[k] for k in range(1,m)):
        print("Yes")
        exit()
print("No")

Solution (Python):
import sys


import math
import collections

import bisect
import itertools
import fractions

import copy
import heapq
import decimal

import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))





def main():
    n, m = ns()
    matA = [list(input()) for _ in range(n)]
    matB = [list(input()) for _ in range(m)]

    a = np.array(matA)
    b = np.array(matB)

    for i in range(n - m + 1):
        for j in range(n - m + 1):
            if np.all(a[j:j + m, i:i + m] == b):
                print("Yes")
                exit(0)

    print("No")


if __name__ == '__main__':
    main()

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

frag='No'
for i in range(n-m+1):
  for j in range(n-m+1):
    for k in range(m):
      if a[i+k][j:j+m]!=b[k]:
        break
    else:
      frag="Yes"
      break
  continue
print(frag)

Solution (Python):
N, M = map(int, input().split())

A = [""] * N
for _ in range(N):
    A[_] = input()

B = [""] * M
for _ in range(M):
    B[_] = input()

import sys
ans = True

for nvi in range(N-M+1):
    for nhi in range(N-M+1):
        ok = True

        for vi in range(M):
            for hi in range(M):
                if A[nvi+vi][nhi+hi] == B[vi][hi]:
                    pass
                else:
                    ok = False
                    break
        
        if ok:
            print("Yes")
            sys.exit()

print("No")

Solution (Python):
n,m=map(int,input().split())
lista=[]
for i in range(n):
    lista.append(input())
listb=[]
for i in range(m):
    listb.append(input())
ans=0
num1=n-m+1
for i in range(num1):
    for j in range(num1):
        yn=0
        for k in range(m):
            str1=lista[i+k]
            if listb[k]!=str1[j:j+m]:
                yn=1
                break
        if yn==0:
            ans=1
            break
    if ans==1:
        break
if ans==0:
    print("No")
else:
    print("Yes")

Solution (Python):
n,m=map(int,input().split())
lista=[]
for i in range(n):
    lista.append(input())
listb=[]
for i in range(m):
    listb.append(input())
ans=0
num1=n-m+1
for i in range(num1):
    for j in range(num1):
        yn=0
        for k in range(m):
            str1=lista[i+k]
            if listb[k]!=str1[j:j+m]:
                yn=1
                break
        if yn==0:
            ans=1
            break
    if ans==1:
        break
if ans==0:
    print("No")
else:
    print("Yes")

Solution (Python):
import numpy as np

N, M = map(int, input().split())
A = np.array([list(input()) for i in range(N)])
B = np.array([list(input()) for i in range(M)])

for i in range(N-M+1):
  for j in range(N-M+1):
    if (A[i:i+M,j:j+M] == B).all():
      print('Yes')
      quit()

print('No')

Solution (Python):
n, m = map(int, input().split())
a = [""] * n
b = [""] * m

for i in range(n):
    a[i] = input()

for i in range(m):
    b[i] = input()

for i in range(n):
    for j in range(n):
        if i + m > n or j + m > n:
            continue
        flag = True
        for k in range(m):
            for l in range(m):
                if a[i + k][j + l] != b[k][l]:
                    flag = False
        if flag is True:
            print("Yes")
            exit(0)

print("No")

Solution (Python):
n, m = map(int, input().split())
A = [str(input()) for _ in range(n)]
B = [str(input()) for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        for x in range(m):
            for y in range(m):
                if A[j+y][i+x] != B[y][x]:
                    break
            else:
                continue
            break
        else:
            print('Yes')
            exit()
else:
    print('No')

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

ans = 'No'
for i in range(n - m + 1):
    for j in range(n - m + 1):
        C = []
        for k in range(m):
            C.append(A[i + k][j : j + m])
        if B == C:
            ans = 'Yes'
            
print(ans)

Solution (Python):
import sys

N, M = map(int, input().split())
A = [list(input()) for i in range(N)]
B = [list(input()) for i in range(M)]

for k in range(N-M+1):
    for i in range(N-M+1):
        a = [A[j+k][i:i+M] for j in range(M)]
        if a == B:
            print('Yes')
            sys.exit()

print('No')

Solution (Python):
if __name__ == '__main__':
    n, m = map(int, input().split())
    lista=[]
    listb =[]
    for i in range(0,n):
        a = input()
        lista.append(a)

    for i in range(0,m):
        a = input()
        listb.append(a)
    flag =0

    for i in range(0,n-m+1):
        for j in range(0,n-m+1):
            count = 0
            for k in range(m):
                if listb[k] == lista[i+k][j:j+m]:
                    count +=1
            if count == m:
                flag=1
    if flag ==1:
        print("Yes")
    else:
        print("No")

Solution (Python):

"""
Created on Sun May 31 13:15:13 2020

@author: NEC-PCuser
"""

N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A.append(input())

for i in range(M):
    B.append(input())

result = "No" 
for i in range(N - M + 1):
    for j in range(N - M + 1):
        for k in range(M):
            for l in range(M):
                if (A[i + k][j + l] != B[k][l]):
                    break
            else:
                continue
            break
        else:
            result = "Yes"
            break

print(result)

Solution (Python):
N,M = map(int,input().split())
a_g=[];b_g=[]
for i in range(N):
  a_g.append(list(input()))
for i in range(M):
  b_g.append(list(input()))

for i in range(N-M+1):
  for j in range(N-M+1):
    flag=1
    for k in range(M):
      for l in range(M):
        if a_g[k+i][l+j] != b_g[k][l]:
          flag=0
          break
    if flag:
      print("Yes");exit()
print("No")

Solution (Python):
N,M = map(int,input().split())

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

ans = 0
for i in range(N-M+1):
    for h in range(N-M+1):
        cnt = 0
        for k in range(M):
            for j in range(M):
                if A[i+k][h+j] != B[k][j]:
                    cnt += 1
        if cnt == 0:
            ans += 1
if ans != 0:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
  num = list(map(int,input().split()))
  n=num[0]
  m=num[1]
  a = [input() for i in range(n)]
  b = [input() for i in range(m)]

  flg=0
  
  for i in range(0 , n):
    if m==1 and a[i].find(b[0])!=-1:
      flg=1
      break
    while n-i >= m and a[i].find(b[0])!=-1:
      start=a[i].find(b[0])
      for j in range(1 , m):
        if a[i+j][start:start+m]!=b[j]:
          break
        if j==m-1:
          flg=1
      if flg==1:
        break
      a[i]=a[i][a[i].find(b[0])+1:]
    if flg==1:
        break
        
  if flg==1:
    print("Yes")
  else:
    print("No")

main()