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 sys

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 k == 0:
                C = [A[i][j:m+j]]
            else:
                C += [A[i+k][j:m+j]]
        if B == C:
            print('Yes')
            sys.exit()
print('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):
        ans = True
        for k in range(m):
            if a[i + k][j:j+m] != b[k]:
                ans = False
        if ans == True:
            break
    else:
        continue
    break

if ans == True:
    print("Yes")
else:
    print("No")

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

for i in range(N):
	a = list(map(str, input()))
	A.append(a)
	
for i in range(M):
	b = list(map(str, input()))
	B.append(b)
	
def foo():
	for si in range(N - M + 1):
		for sj in range(N - M + 1):
			flg = 1
			for i in range(M):
				if not A[si + i][sj : sj + M] == B[i]:
					flg = 0
					break
			if flg:
				print("Yes")
				return 0
	print("No")
	return 0
	
foo()

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):
        for ii in range(M):
            for jj in range(M):
                if A[i+ii][j+jj] != B[ii][jj]:
                    break
            else:
                continue
            break
        else:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")

Solution (Python):
from itertools import zip_longest
N, M = map(int, input().split())

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

def isSame(h, w):
    for lineA, lineB in zip_longest(A[h: h + M], B, fillvalue=[]):
        for a, b in zip_longest(lineA[w: w + M], lineB, fillvalue='?'):
            if a != b:
                return False
    return True

for h in range(N):
    for w in range(N):
        if isSame(h, w):
            print('Yes')
            exit()

print('No')

Solution (Python):

N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
n = 0
n2 = 1

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

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


for i in range(n + 1 - m):
    
    for j in range(n + 1 - m):
        k = 0
        while 1:
            if a[i + k][j:j+m] != b[k]:
                break
            else:
                if k == m - 1:
                    print("Yes")
                    exit()
                k += 1
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())
flag = 0
for i in range(N-M+1):
    for k in range(N-M+1):
        p = 1
        for j in range(i,i+M):
            a = A[j][k:k+M]
            b = B[j-i]
            if a != b:
                p = 0
                break
        if p == 1:
            flag = 1
        

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

Solution (Python):
N,M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for j in range(M)]
W = len(list(A[0]))-len(list(B[0]))+1
H = N - M + 1
ans = "No"
for i in range(H):
    for j in range(W):
        tmpA = []
        for k in range(M):
             tmpA.append(A[i+k][j:j+len(list(B[0]))])
        if tmpA == B:
            ans = "Yes"
            break
print(ans)

Solution (Python):
n,m=map(int,input().split())
a=[input() for i in range(n)]
b=[input() for i in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        frag=True
        for y in range(m):
            for x in range(m):
                if b[y][x]!=a[i+y][j+x]:
                    frag=False
        if frag==True:
            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)]
for y in range(n-m+1):
    for x in range(n-m+1):
        failed = False
        for by in range(m):
            for bx in range(m):
                if a[x+bx][y+by] != b[bx][by]:
                    failed = True
        if failed == False:
            print("Yes")
            exit()
print("No")

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



for i in range(N-M+1):
    for j in range(N-M+1):
        result = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    result = False
        if result:
            print("Yes")
            exit()




print("No")

Solution (Python):
N,M = map(int,input().split())
A = [[x for x in input()] for i in range(N)]
B = [[x for x in input()] for i in range(M)]
result = "No"


for i in range(N-M+1):
    for j in range(N-M+1):
        result = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    result = False
        if result:
            print("Yes")
            exit()




print("No")

Solution (Python):
N, M = map(int, input().split())
Alist = [list(input()) for _ in range(N)]
Blist = [list(input()) for _ in range(M)]
from sys import exit
for i in range(N - M + 1):
    for j in range(N - M + 1):
        for A, B in zip(Alist[i:i + M], Blist):
            if A[j:j + M] != B:
                break
        else:
            print("Yes")
            exit()
print("No")

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

for i in range(N - M + 1):
    for j in range(N - M + 1):

        if B[0] == A[i][0+j:M+j]:
            for k in range(M):
                temp1 = B[k]
                temp2 = A[i + k][0+j:M+j]
                if B[k] != A[i + k][0+j:M+j]:
                    break
            else:
                flag = True
                break
    if flag:
        break

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

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

An = [ input() for _ in range(N)]
Bn = [ input() for _ in range(M)]
flag = False
for i in range(N-M+1):
    for j in range(N-M+1):
        for s in range(M):
            a = An[i+s][j:j+M]
            b =Bn[s]
            if An[i+s][j:j+M] != Bn[s]:
                break
            if s == M-1:
                flag = True
print('Yes' if flag else 'No')

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

A = []
B = []
for _ in range(N):
    tmp = input()
    tmp = tmp.replace("
    tmp = tmp.replace(".", "2")
    tmp = [int(i) for i in tmp]
    A.append(tmp)

for _ in range(M):
    tmp = input()
    tmp = tmp.replace("
    tmp = tmp.replace(".", "2")
    tmp = [int(i) for i in tmp]
    B.append(tmp)

A = np.array(A)
B = np.array(B)

ans = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        if np.all(A[i:i+M, j:j+M] == B):
           ans = 1

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

Solution (Python):
N,M=map(int,input().split())
A=[]
B=[]
ans="Yes"
for _ in range(N):
  A.append(input().split())
for __ in range(M):
  B.append(input().split())
for i in range(N):
  for k in range(M):
    if B[k][0] not in A[i][0]:
       ans ="No"
      
print(ans)

Solution (Python):
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
ans = 'Yes'
for i in range(n):
    for j in range(m):
        if b[j] not in a[i]:
            ans = 'No'
print(ans)

Solution (Python):
n, m = map(int, input().split())
nn = []
mm = []
for i in range(n):
    nn.append(list(input()))
for i in range(m):
    mm.append(list(input()))
for i in range(n-m+1):
    for j in range(n-m+1):
        count = 0
        for k in range(m):
            for l in range(m):
                if nn[i+k][j+l] != mm[k][l]:
                    break
                else:
                    count += 1
        if count == m*m:
            print("Yes")
            exit()
print("No")

Solution (Python):
n,m=map(int,input().split())
A=[list(input()) for i in range(n)]
B=[list(input()) for j in range(m)]
point=[[i,j] for i in range(m) for j in range(m)]
for i in range(n-(m-1)):
    for j in range(n-(m-1)):
        cnt=0
        for x,y in point:
            if B[x][y]==A[i+x][j+y]:
                cnt +=1
        if cnt==m**2:
            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)]


for i in range(N-M+1):
    for j in range(N-M+1):
        
        if A[i][j] == B[0][0]:  
            flag = True
            
            for n in range(i, i+M):
                for m in range(j, j+M):
                    
                    if A[n][m] != B[n-i][m-j]:
                        flag = False
            if flag:
                print("Yes")
                exit()
print("No")

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

for X in range(N-M+1):
    for Y in range(N-M+1):
        flag=1
        for x in range(M):
            for y in range(M):
                if B[x][y]!=A[x+X][y+Y]:
                    flag=0
                    break
            if not flag:
                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)]

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]:
          flag = False
    if flag:
      print('Yes')
      exit()
print('No')

Solution (Python):
N,M = map(int,input().split())
A = []
B = []
for _ in range(N):
  A.append(input())
for _ in range(M):
  B.append(input())
for a,b in zip(A,B):
  if b in a:
    flag = True
  else:
    flag = False
    break;
if flag:
  print('Yes')
else:
  print('No')

Solution (Python):
def examB():
    N, M = LI()
    A = [S() for _ in range(N)]
    B = [S() for _ in range(M)]
    loop = N-M+1
    ans = "No"
    for i in range(loop):
        for j in range(loop):
            cur = int(0)
            for k1 in range(M):
                for k2 in range(M):
                    if A[i+k1][j+k2]==B[k1][k2]:
                        cur +=1
            if cur==M**2:
                ans = "Yes"
    print(ans)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

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

for p in range(N-M+1):
    for q in range(N-M+1):
        data=[[A[p+j][q+i] for i in range(M)]  for j in range(M)]
        if data == B:
            ans=True
            break
        else:
            ans=False
            continue
    if ans:break
if ans:print('Yes')
else:print('No')

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


def check_in(add_tate, add_yoko):
    for A, B in zip(Alist[add_tate:add_tate + M], Blist):
        try:
            assert A[add_yoko:add_yoko + M] == B
        except AssertionError:
            return False
    return True


from sys import exit
if Alist == Blist:
    print("Yes")
    exit()
for add_tate in range(N - M):
    for add_yoko in range(N - M):
        if check_in(add_tate, add_yoko):
            print("Yes")
            exit()
print("No")

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

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 h in range(N-M+1):
    for w in range(N-M+1):
        if A[h][w]==B[0][0]:
            k = 1
            for h1 in range(M):
                for w1 in range(M):
                    if A[h+h1][w+w1]!=B[h1][w1]:
                        k=0
                        break
                if not k:break
            if k:ans="Yes"
print(ans)

Solution (Python):
n,m=map(int,input().split())
l1=[]
l2=[]
for i in range(n):
  w=list(input())
  l1.append(w)
for i in range(m):
  w=list(input())
  l2.append(w)
d=n-m
b1=False
for i in range(d+1):
  for j in range(d+1):
    b=True
    for k in range(m):
      for h in range(m):
        if l2[k][h]!=l1[i+k][j+h]:
          b=False
    if b:
      b1=True
if b1:
  print("Yes")
else:
  print("No")

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

flag = "No"
diff = n - m + 1
for i in range(diff):
  for j in range(diff):
    T = []
    for k in range(m):
      T.append(A[i+k][j:j+m])
    if T == B:
      flag = "Yes"
      break

print(flag)

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):
        if b == [w[j:j+m] for w in a[i:i+m]]:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("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):
    c = True
    for k in range(m):
      if a[i+k][j:j+m] != b[k]:
        c = False
    if c:
      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 = 'No'

for i in range(n - m + 1):
    for j in range(n - m + 1):
        sub_a = [a[i + k][j:j+m] for k in range(m)]
        if sub_a == b:
            ans = 'Yes'

print(ans)

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

count=0

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 b[k][l]==a[i+k][j+l]:
                    count+=1

                else:
                    count=0
                    break
            if count==0:
                break
            
        if count==m**2:
            print('Yes')
            exit()
        
print('No')

Solution (Python):
n, m = map(int, input().split())
a = [[c for c in input()] for i in range(n)]
b = [[v for v in input()] for j in range(m)]
exist = False
for y in range(n):
    for x in range(n):
        if y+m-1 >= n or x+m-1 >= n: continue
        match = True
        for by in range(m):
            for bx in range(m):
                if a[y+by][x+bx] != b[by][bx]: match = False
        if match: exist = True
print('Yes' if exist else 'No')

Solution (Python):
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7


def main():
    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):
            f = True
            for p in range(m):
                for q in range(m):
                    if a[i + p][j + q] != b[p][q]:
                        f= False
            
            if f:
                print("Yes")
                exit()

    print("No")


if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
gazoa=[0 for i in range(n)]
gazob=[0 for j in range(m)]
for i in range(n):
    s=input()
    gazoa[i]=s
for j in range(m):
    s=input()
    gazob[j]=s
flag=False
for i in range(n-m+1):
    
    for k in range(n-m+1):
        realflag=True
        
        for num in range(m):
            if gazoa[i+num][k:k+m]!=gazob[num]:
                realflag=False
        if realflag:
            flag=True
if flag:
    print("Yes")
        
        
else:
    print("No")

Solution (Python):
N,M=map(int,input().split())
A=[];B=[]
for i in range(N):
    Ai=input()
    A.append([Ai[j]=='
for i in range(M):
    Bi=input()
    B.append([Bi[j]=='
fans=False
fnext=False
for k in range(N-M+1):
    if fans:
        break
    for l in range(N-M+1):
        if fans:
            break      
        if fnext:
            fnext=False
        for i in range(M):
            if fnext:
                break
            for j in range(M):                    
                if A[k+i][l+j]!=B[i][j]:
                    fnext=True
                    break
                if i==j==M-1:
                    fans=True

print('Yes' if fans else 'No')

Solution (Python):
def main():
    n,m = map(int,input().split()) 
    a=[]
    b=[]
    for _ in range(n):
        a.append( list(input()) )
    for _ in range(m):
        b.append( list(input()) )
    key=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 b[x][y]==a[i+x][j+y]:
                        continue
                    else:
                        key=1
                        break
                if key==1:
                    break
            if key == 0:
                print("Yes")
                return
            key=0
    print("No")
main()

Solution (Python):
n,m = map(int,input().split())
a = [input() for _ 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):
        if a[i][j:j+m] == b[0]:
            for k in range(i+1,i+m):
                if a[k][j:j+m] != b[k-i]:
                    break
            else:
                ans = 'Yes'
print(ans)

Solution (Python):
n, m = [int(x) for x in input().split()]
img_a = [input() for _ in range(n)]
img_b = [input() for _ in range(m)]

found = False
for a in range(n - m + 1):
    border = 0
    isok = True
    while isok and not found:
        for b in range(m):
            if img_b[b] in img_a[b+a][border:]:
                if b == 0:
                    index = img_a[a].index(img_b[0], border)
                current_index = img_a[b+a].index(img_b[b], border)
                if current_index == index:
                    continue
                elif current_index > index:
                    border = current_index
                    break
                else:
                    border = index
                    break
            else:   
                isok = False
                break

        else: 
            ans = "Yes"
            found = True
            break
    if found:
        break
else: 
    ans = "No"
        
print(ans)

Solution (Python):
n, m = [int(x) for x in input().split()]
img_a = [input() for _ in range(n)]
img_b = [input() for _ in range(m)]

flag = False
for a in range(n - m + 1):
    border = 0
    isok = True
    while isok and not flag:
        for b in range(m):
            if img_b[b] in img_a[b+a][border:]:
                if b == 0:
                    index = img_a[a].index(img_b[0], border)
                current_index = img_a[b+a].index(img_b[b], border)
                if current_index == index:
                    continue
                elif current_index > index:
                    border = current_index
                    break
                else:
                    border = index
                    break
            else:   
                isok = False
                break

        else: 
            ans = "Yes"
            flag = True
            break
    if flag:
        break
else:
    ans = "No"
        
print(ans)

Solution (Python):
n, m = [int(x) for x in input().split()]
img_a = [input() for _ in range(n)]
img_b = [input() for _ in range(m)]

ans = "No"
for a in range(n - m + 1):
    border = 0
    isok = True
    while isok:
        for b in range(m):
            if img_b[b] in img_a[b+a][border:]:
                if b == 0:
                    index = img_a[a].index(img_b[0], border)
                current_index = img_a[b+a].index(img_b[b], border)
                if current_index == index:
                    continue
                elif current_index > index:
                    border = current_index
                    break
                else:
                    border = index
                    break
            else:   
                isok = False
                break

        else: 
            ans = "Yes"
            break
        
print(ans)

Solution (Python):
n, m = [int(x) for x in input().split()]
img_a = []
img_b = []

for i in range(n):
    img_a.append(input())

for i in range(m):
    img_b.append(input())

ans = "No"
for a in range(n - m + 1):
    border = 0
    flag = True
    while flag:
        for b in range(m):
            if img_b[b] in img_a[b+a][border:]:
                if b == 0:
                    index = img_a[a].index(img_b[0], border)
                current_index = img_a[b+a].index(img_b[b], border)
                if current_index == index:
                    continue
                elif current_index > index:
                    border = current_index
                    break
                else:
                    border = index
                    break
            else:   
                flag = False
                break

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

ans = 'No'

for l_i in range(n-m+1):
  for n_i in range(n-m+1):
    sub_A = [A[l_i+m_i][n_i:n_i+m] for m_i in range(m)]
    if sub_A == B:
      ans = 'Yes'
      
print(ans)

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

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

for i in range(N - M + 1):
    for j in range(N - M + 1):
        A_ = "".join([A[k][j:(j+M)] for k in range(i, i + M)])
        if B == A_:
            print("Yes")
            exit()
print("No")

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


def pat_match(Temp, temp_w, temp_h, Big_pic, ind_w, ind_h):
  for i in range(temp_h):
    for j in range(temp_w):
      if Temp[i][j] != Big_pic[i + ind_w][j + ind_h]:
        return False
  else:
    return True


import sys
for i in range(0, n-m+1):
  for j in range(0, len(A[0]) - len(B[0]) + 1):
    if pat_match(B, len(B[0]), m, A, j, i):
      print("Yes")
      sys.exit()
else:
  print("No")

Solution (Python):
N, M = map(int, input().split())
imgA = [input() for i in range(N)]
imgB = [input() for i in range(M)]
flag = -1
flags = []

for i in range(N - M + 1):
    while True:
        flag = imgA[i].find(imgB[0], flag+1)
        if flag >= 0:
            for j in range(1, M):
                if imgA[i+j].find(imgB[j], flag) == flag:
                    continue
                else:
                    break
            else:
                print('Yes')
                exit()
        else:
            break
else:
    print('No')

Solution (Python):
N,M = map(int,input().split())
A = [input().strip() for _ in range(N)]
B = [input().strip() for _ in range(M)]
for i in range(N-M+1):
    for j in range(N-M+1):
        flag = 0
        for k in range(M):
            for l in range(M):
                if B[k][l] != A[i+k][j+l]:
                    flag=1
                    break
            if flag==1:break
        if flag==0:break
    if flag==0:break
if flag==0:
    print("Yes")
else:
    print("No")

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

for i in a:
    for j in b:
        if j not in i:
            print('No')
            quit()
print('Yes')

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def check(i,j):
    for k in range(m):
        for l in range(m):
            if a[i+k][j+l] != b[k][l]:
                return False
    return True

n,m = inpl()
a = []
b = []
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())

bb = True
for i in range(n-m+1):
    for j in range(n-m+1):
        if check(i,j):
            print('Yes')
            quit()
print('No')

Solution (Python):
import numpy as np
n, m = map(int, input().split())
a = np.zeros((n, n))
b = np.zeros((m, m))
for i in range(n):
    for j, s in enumerate(input()):
        if s == "
for i in range(m):
    for j, s in enumerate(input()):
        if s == "
for i in range(n - m + 1):
    for j in range(n - m + 1):
        sa = a[i:i+m, j:j+m]
        if not np.sum(np.logical_xor(sa, b)):
            print("Yes")
            exit()
print("No")

Solution (Python):
N,M = map(int,input().split())
A = []
B = []
ans = 'No'
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())
for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:M+j+1] == B[0]:
            D = 0
            for k in range(i,i+M):
                for l in range(0,M):
                    if A[k][j:M+j+1] == B[l]:
                        D += 1
            if D == M:
                ans = 'Yes'
if ans == 'Yes':
    print('Yes')
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())
def check(i,j): 
    if i+m>n or j+m>n:
        return 0 
    a1=-1 
    for x in range(i,i+m):
        a1+=1 
        b1=0 
        for y in range(j,j+m):
            if b[a1][b1]!=a[x][y]:
                return 0 
            b1+=1 
    return 1 
for i in range(n):
    for j in range(n): 
        if check(i,j):
            print('Yes')
            exit()
print('No')

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

for i in range(N - M + 1):
  for j in range(N - M + 1):
    
    count = 0
    for k in range(M):
      for l in range(M):
        if B[k][l] != A[i + k][j + l]:
          count += 1
    if count == 0:
      print("Yes")
      quit()
  
print("No")

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


def solve():
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            c = ""
            for k in range(m):
                c += a[i + k][j : j + m]
            if "".join(b) == c:
                print("Yes")
                return
    print("No")


solve()

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

Solution (Python):
N,M = map(int,input().split())
A = [0] * N
B = [0] * M

ans = "No"

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

for j in range(M):
    B[j] = list(input())

for k in range(N-M+1):
    for l in range(N-M+1):
        det = 0
        for x in range(M):
            for y in range(M):
                if A[k+x][l+y] != B[x][y]:
                    det = -1
        if det == 0:
            ans = "Yes"

print(ans)

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

ok = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        tmp = [a[k][j: j + m] for k in range(i, i + m)]
        if tmp == b:
            ok = True
            break
if ok:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
input = sys.stdin.readline


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

    for ay in range(0, N-M+1):
        for ax in range(0, N-M+1):
            m = 0
            for by in range(M):
                for bx in range(M):
                    if A[ay + by][ax + bx] == B[by][bx]:
                        m += 1
                        if m == M*M:
                            print("Yes")
                            return
    print("No")


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 check():
    for i in range(n-m+1):
        for j in range(n-m+1):
            for k in range(m):
                if b[k] != a[j+k][i:i+m]:
                    break
            else:
                return "Yes"

    return "No"

ans = check()

print(ans)