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):
n,m=map(int,input().split())
a=[list(input()) for i in range(n)]
b=[list(input()) for i in range(m)]
count=0
flag=False
for i in range(len(a)-len(b)+1):
  for j in range((len(a[0])-len(b[0])+1)):
    s=[]
    for k in range(i,i+len(b)):
      s.append(a[k][j:j+len(b[0])])
    count=0
    for l in range(m):
      if s[l]==b[l]:
        count+=1
      if count==m:
        flag=True
if flag:
  print("Yes")
else:
  print("No")

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

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

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


def f(r, c):
    if r+M > N or c+M > N:
        return False
    for i in range(M):
        if A[r+i][c:c+M] != B[i]:
            return False
    return True


def main():
    for i in range(N):
        for j in range(N):
            if f(i,j):
                print("Yes")
                return 
    print("No")

main()

Solution (Python):
N, M = map(int,input().split())
A = [[] for _ in range(N)]
B = [[] for _ in range(M)]
for i in range(N):
    A[i] = input()
for j in range(M):
    B[j] = input()
for k in range(N-M+1):
    for l in range(N-M+1):
        f = 0
        for p in range(M):
            for q in range(M):
                if not A[k+p][l+q] == B[p][q]:
                    f = 1
                    break
            if f == 1:
                break
        if f == 0:
            print('Yes')
            exit()
print('No')

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


for i in range(n-m+1):
    for j in range(n-m+1):
        jugh=True
      
        for x in range(m):
            for y in range(m):
         
                if a[x+i][y+j]!=b[x][y]:
                    jugh=False
                   
                    break
        if jugh==True:
            print("Yes")
            exit()

print("No")

Solution (Python):
import sys

N, M = map(int, input().split())

As = []
for i in range(N):
    As.append(list(input()))

Bs = []
for i in range(M):
    Bs.append(list(input()))


def isEqual(A_i, A_j):
    try:
        for i in range(M):
            for j in range(M):
                if As[A_i+i][A_j+j] != Bs[i][j]:
                    return
    except IndexError:
        return

    print('Yes')
    sys.exit(0)


for A_i in range(N):
    for A_j in range(N):
        isEqual(A_i, A_j)

print('No')

Solution (Python):
import sys

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):
    f = True
    for k in range(m):
      for l in range(m):
        if a[i+k][j+l] != b[k][l]:
          f = False
    if f == True:
      print("Yes")
      sys.exit()
      
print("No")

Solution (Python):
N, M = [int(i) for i in input().split()]
a = [list(input()) for _ in range(N)]
b = [list(input()) for _ in range(M)]

flag = False

for i in range(N-M+1):
    for j in range(N-M+1):
        if b == [a[k+i][j:j+M] for k in range(M)]:
            flag = True

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

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

flag = False

if n == m:
    for i in range(n):
        for j in range(n):
            if ai[i][j] != bi[i][j]:
                print('No')
                exit()
    print('Yes')
    exit()

for i in range(n-m):
    if flag == True:
        break
    for j in range(n-m):
        if flag == True:
            break
        for k in range(m):
            flag = True
            for l in range(m):
                if bi[k][l] != ai[i+k][j+l]:
                    flag = False
                    break
            if flag == False:
                break

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

Solution (Python):
def resolve():
	n, m = map(int, input().split())
	A = []
	B = []
	ans = False
	for _ in range(n):
		A.append(list(input()))
	for _ in range(m):
		B.append(list(input()))
	for i in range(n):
		for j in range(n):
			if i + m - 1 >= n or j + m - 1 >= n:
				continue
			tmp_ans = True
			for k in range(m):
				for l in range(m):
					if A[i+k][j+l] != B[k][l]:
						tmp_ans = False
						break
			if tmp_ans:
				ans = 'Yes'


	if ans:
		print('Yes')
	else:
		print('No')
resolve()

Solution (Python):
n, m = map(int, input().split())
an = [input() for _ in range(n)]
bn = [input() for _ in range(m)]
diff = n-m+1
flag = False
for i in range(diff):
    for j in range(diff):
        if [a[j:m+j] for a in an[i:m+i]] == bn:
            flag = True
print('Yes' if flag else '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)]
flag = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        
        cnt = 0
        for k in range(m):
            for l in range(m):
                if a[i + k][j + l] == b[k][l]:
                    cnt += 1
                if cnt == m ** 2:
                    flag = True
if flag:
    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)]

diff = N - M
for i in range(diff+1):
    for j in range(diff+1):
        flag = True
        for k in range(M):
            if not (B[k] in A[j+k][i:i+M]):
                flag = False
        if flag:
            print('Yes')
            exit(0)

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

trm = [""] * M

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

Solution (Python):
def resolve():
    N, M = list(map(int, input().split()))
    A = [input() for i in range(N)]
    B = [input() for i in range(M)]
    for i in range(0, N-M+1):
        for j in range(0, N-M+1):
            flg = True
            for a, b in zip(A[i:i+M], B):
                if a[j:j+M] != b:
                    flg = False
                    break
            if flg:
                print("Yes")
                return
    print("No")
if '__main__' == __name__:
    resolve()

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False



def main():
    N, M = MI()
    A = [[None] * N for i in range(N)]
    B = [[None] * M for i in range(M)]

    for i in range(N):
        s = S()
        for j in range(N):
            A[i][j] = s[j]

    for i in range(M):
        s = S()
        for j in range(M):
            B[i][j] = s[j]

    for i in range(N-M+1):
        for j in range(N-M+1):
            f = []
            for m in range(M):
                for n in range(M):
                    f.append(A[i+m][j+n] == B[m][n])

            if all(f):
                print('Yes')
                return

    print('No')


if __name__ == '__main__':
    main()

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

A = [[0]]*N
B = [[0]]*M

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

judge = False 


for k in range(N-M+1):
    for i in range(N-M+1):
        count = 0
        for j in range(M):
            if B[j]==A[j+i][k:k+M]:
                count += 1
                
                if count == M:
                    judge = True
                    break
            
if judge == True:
    print("Yes")
else:
    print("No")

Solution (Python):
nums = [int(e) for e in input().split()]
STR1=[]
STR2 = []
count = 0
ans = 0
for i in range(nums[0]):
    s=input()
    t = len(s)
    STR1.append(s)
for k in range(nums[1]):
    s = input()
    u = len(s)
    STR2.append(s)
for i in range(nums[0] - nums[1] +1):
    for k in range(t-u+1):
        if(STR2[0][0] == STR1[i][k]):
            count = 0
            for j in range(nums[1]):
                for l in range(u):
                    if(STR2[j][l] != STR1[i+j][k+l]):
                        break
                else:
                    count += 1
            if(count == nums[1]):
                ans += 1
if(ans == 0):
    print('No')
else:
    print('Yes')

Solution (Python):
nums = [int(e) for e in input().split()]
STR1=[]
STR2 = []
count = 0
ans = 0
for i in range(nums[0]):
    s=input()
    t = len(s)
    STR1.append(s)
for k in range(nums[1]):
    s = input()
    u = len(s)
    STR2.append(s)
for i in range(nums[0] - nums[1] +1):
    for k in range(t-u+1):
        if(STR2[0][0] == STR1[i][k]):
            count = 0
            for j in range(nums[1]):
                for l in range(u):
                    if(STR2[j][l] != STR1[i+j][k+l]):
                        break
                else:
                    count += 1
            if(count == nums[1]):
                ans += 1
if(ans == 0):
    print('No')
else:
    print('Yes')

Solution (Python):
n,m=map(int,input().split())
a=[input()for _ in range(n)]
b=[input()for _ in range(m)]
f=False
l=n-m+1
for i in range(l):
      for j in range(l):
            f1=True
            for  k in range(m):
                  if b[k]==a[i+k][j:j+m]:
                        continue
                  else:
                        f1=False
                        break
            if f1:
                  f=True
                  break                        
print('Yes' if f else 'No')

Solution (Python):
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-m+1):
    for j in range(len(a[0])-len(b[0])+1):
        count = 0
        if b[0] == a[i][j:j+len(b[0])]:
            
            for k in range(m):
                if b[k] == a[i+k][j:j+len(b[0])]:
                    count += 1
            if count == m:
                print("Yes")
                exit()

print("No")

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

for i in range(n-m+1):
    for j in range(n-m+1):
        find = True
        for k in range(m):
            if not a[i+k][j:j+m] == b[k]:
                find = False
                break
        if find:
            print("Yes");sys.exit()
print("No")

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

flag = 0
def solve():
    global flag
    if n == m:
        if a == b:
            flag = 1
        return 
    
    for i in range(n-m):
        for j in range(n-m):
            z = 0
            while a[i+z][j:j+m] == b[z]:
                if z == m-1:
                    flag = 1
                    break
                z += 1
    return

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

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

mc = n-m+1
ans = False
for ai in range(0, mc):
  if(ans):
    break
  ind = [x.start() for x in re.finditer(b[0], a[ai])]
  if(m==1)and(len(ind)>0):
    ans=True
    break  
  for i in ind:
    if(ans):
      break
    for bi in range(1, m):
      if(a[ai+bi][i:i+m] != b[bi]):
        break
      if(bi==m-1):
        ans = True
        break
if(ans):
  print('Yes')
else:
  print('No')

Solution (Python):
N, M = map(int, input().split())
a = list(str(input()) for _ in range(N))
b = list(str(input()) for _ in range(M))

import sys
c = N-M + 1

for a_j in range(c):
    for start_a in range(c):
        for a_i, b_i in zip(range(start_a, start_a+M), range(M)):
            if a[a_i][a_j:a_j+M] == b[b_i]:
                is_match = True
            else:
                is_match = False
                break
        if is_match:
            print("Yes")
            sys.exit()

print("No")

Solution (Python):

n, m = map(int, input().split())

A = []
for _ in range(n):
    row = list(input())
    A.append(row)

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

def check(A, B, x, y):
    for i in range(m):
        for j in range(m):
            if B[i][j] == A[x + i][y + j]:
                continue
            else:
                return False
    return True

def main():
    for i in range(n):
        for j in range(n):
            if A[i][j] == B[0][0] and i + m <= n and j + m <= n:
                if check(A, B, i, j):
                    print('Yes')
                    return
    print('No')

if __name__ == "__main__":
    main()

Solution (Python):
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    A = str(input())
    a.append(A)
for j in range(m):
    B = str(input())
    b.append(B)
for i in range(n-m+1):
    for j in range(n-m+1):
        flag = 0
        for k in range(m):
            if a[i + k][j:j + m] != b[k]:
                flag += 1
        if flag == 0:
            print("Yes")
            exit()
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())
c=0
for i in range(n-m+1):
    for j in range(n-m+1):
        p = [l[j:j+m] for l in a[i:i+m]]
        if b == p and c==0:
            print('Yes')
            c=1
            break
if c==0:
    print('No')

Solution (Python):
N,M=map(int, input().split())
N_str = []
M_str = []
for i in range(N):
  n=str(input())
  N_str.append(n)
for i in range(M):
  m=str(input())
  M_str.append(m)

equal = False
  
for i in range(N-M+1):
  for k in range(N-M+1):
    each_equal = True
    for l in range(M):
      each_equal = each_equal and (N_str[i+l][k:k+M] == M_str[l])
    equal = equal or each_equal

print(["No","Yes"][equal])

Solution (Python):
N,M=map(int,input().split())
L=[]
X=[]
for i in range(N):
	L.append(input())
for i in range(M):
	X.append(input())
for i in range(N-M+1):
	for j in range(N-M+1):
		if L[i][j]==X[0][0]:
			ans=0
			for x in range(M):
				for y in range(M):
					if L[i+x][j+y]==X[x][y]:
						ans+=1
			if ans==(M**2):
				print("Yes")
				exit()
print("No")

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

a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
for i in range(n):
    for j in range(n):
        if a[i][j] == b[0][0] and i + m - 1 < n and j + m - 1 < n:
            flag = 1
            for y in range(m):
                for x in range(m):
                    if a[i + y][j + x] != b[y][x]:
                        flag = 0
                        break
                
            if flag == 1:
                print("Yes")
                exit()

print("No")

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

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

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()))
p = 1
for i in range(n-m+1):
    for j in range(n-m+1):
        if p == 1:
            p = 0
        elif p == 0:
            break
        for k in range(m):
            if p == 1:
                break
            for l in range(m):
                if b[k][l] != a[k+j][l+i]:
                    p = 1
                    break
if p == 0:
    print("Yes")
elif p == 1:
    print("No")

Solution (Python):
x, y = map(int,input().split())
a = []
b = []

for i in range(x):
    a.append(list(input()))
for i in range(y):
    b.append(list(input()))

for i in range(x-y+1): 
    for j in range(x-y+1): 
        flag = 1
        for k in range(y): 
            if b[k] != a[i+k][j:j+y]:
                flag = 0
                break
        if flag == 1:
            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 i in range(m)]
c = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        p = [l[j:j+m] for l in a[i:i+m]]
        if b == p and c==0:
            print('Yes')
            c=1
            break
if c==0:
    print('No')

Solution (Python):
def match(y, x):
    ret = True
    for i in range(M):
        for j in range(M):
            if A[y + i][x + j] != B[i][j]:
                ret = False
    return ret
N, M = map(int, input().split())
A = []
for i in range(N):
    A.append(list(input()))
B = []
for i in range(M):
    B.append(list(input()))
flg = False
for i in range(N - M + 1):
    for j in range(N - M + 1):
        if match(i, j):
            flg = True
print("Yes" if flg else "No")

Solution (Python):
import numpy as np

def ABC054B(n,  m, a, b):
    def makeBoard(n, a):
        A = np.zeros((n, n), dtype=str)
        for i, s in enumerate(a):
            
            A[i, :] = list(s)
        return A
    A = makeBoard(n, a)
    B = np.reshape(makeBoard(m, b), (m*m,))
    ans = 'No'
    if n >= m:
        for i in range(n-m+1):
            for j in range(n-m+1):
                if all(B == np.reshape(A[i:i+m, j:j+m], (m*m,))):
                    ans = 'Yes'
                    break
            if ans == 'Yes':
                break
    print(ans)

n, m = map(int, input().split())
a = [0] * n
b = [0] * m
for i in range(n):
    a[i] = input()
for i in range(m):
    b[i] = input()
ABC054B(n, m, a, b)

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


def inputlist():
  return [int(j) for j in input().split()]


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

Solution (Python):
N,M = [int(i) for i in input().split()]
big = []
small = []
flag = 0

for i in range(N):
    a = input()
    big.append(a)
for i in range(M):
    a = input()
    small.append(a)

for i in range(0,N-M+1):
    for j in range(0,N-M+1):
        if big[i][j] == small[0][0]:
            count = 0
            for k in range(M):
                for l in range(M):
                    if big[i+k][j+l] == small[k][l]:
                        count += 1
                    if k == M-1 and l == M-1 and count == M * M:
                        flag = 1
                        break

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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

ans = False
for ha in range(N):
    for wa in range(N):
        flag = True
        for hb in range(M):
            for wb in range(M):
                if ha + hb >= N or wa + wb >= N:
                    flag = False
                    continue
                if A[ha + hb][wa + wb] != B[hb][wb]:
                    flag = False

        ans |= flag

print("Yes" if ans else "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()))

c = n - m + 1
ans = "No"
for i in range(c):
    for j in range(c):
        flag = True
        for p in range(m):
            for q in range(m):
                if a[i+p][j+q] != b[p][q]:
                    flag = False
                    break
        if flag == True:
            ans = "Yes"
            break
print(ans)

Solution (Python):
N,M = [int(i) for i in input().split()]
An = []
Am = []
for i in range(N):
    a = input()
    An.append(a)
for i in range(M):
    a = input()
    Am.append(a)

a = 0
b = 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 An[i][j] == Am[0][0]:
                    if An[i+l][j+k] == Am[l][k]:
                        a += 1
                        if a == M*M:
                            b = 1
                        continue
                    else:
                        a = 0
                        break
                else:
                    a = 0
                    break

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

Solution (Python):

def match(start_x, start_y):
    count = 0
    for x in range(m):
        for y in range(m):
            if a[start_x+x][start_y+y] == b[x][y]:
                count += 1

    return count // m**2


def main():
    count_match = 0
    for x in range(n - m + 1):
        for y in range(n - m + 1):
            count_match += match(x, y)

    if count_match != 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    n, m = map(int, input().split())
    a = [list(input()) for i in range(n)]
    b = [list(input()) for i in range(m)]
    main()

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

ans = 'No'
for i in range(0,n-m+1):
    for j in range(0,n-m+1):
        if a_l[i][j] == b_l[0][0]:
            for k in range(m):
                judge = a_l[i+k][j:j+m] == b_l[k]
                if judge == False:
                    break
            else:
                ans = 'Yes'

print(ans)

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

if N == M:
    for i in range(N):
        if A[i] != B[i]:
            print("No")
            exit()
    print("Yes")
    exit()

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

Solution (Python):
import sys
N, M = map(int,input().split())
A = []
B = []
for _ in range(N):
    A.append(input())
for _ in range(M):
    B.append(input())
for i in range(N - M + 1):
    for j in range(N - M + 1):
        flag = 1
        for h in range(M):
            if A[h+i][j:j+M] != B[h]:
                flag = 0
        if flag:
            print('Yes')
            sys.exit()
print('No')

Solution (Python):
N,M = [int(i) for i in input().split()]
big = []
small = []
flag = 0

for i in range(N):
    a = input()
    big.append(a)
for i in range(M):
    a = input()
    small.append(a)

for i in range(0,N-M+1):
    for j in range(0,N-M+1):
        if big[i][j] == small[0][0]:
            count = 0
            for k in range(M):
                for l in range(M):
                    
                    
                    
                    
                    
                    
                    
                    if big[i+k][j+l] == small[k][l]:
                        count += 1
                    if k == M-1 and l == M-1 and count == M * M:
                        flag = 1

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

Solution (Python):
N,M = [int(i) for i in input().split()]
big = []
small = []
flag = 0

for i in range(N):
    a = input()
    big.append(a)
for i in range(M):
    a = input()
    small.append(a)

for i in range(0,N-M+1):
    for j in range(0,N-M+1):
        if big[i][j] == small[0][0]:
            count = 0
            for k in range(M):
                for l in range(M):
                    
                    
                    
                    
                    
                    
                    if big[i+k][j+l] == small[k][l]:
                        count += 1
                    if k == M-1 and l == M-1 and count == M * M:
                        flag = 1

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

Solution (Python):
def resolve():
	n, m = map(int, input().split())
	a = []
	sb = ""
	ans = "No"
	for _ in range(n):
		a.append(input())
	for _ in range(m):
		sb += input()
	for i in range(n-m or n):
		for j in range(n-m or n):
			sa = ""
			for k in range(m):
				sa += a[i+k][j:j+m]
			if sa == sb:
				ans = "Yes"
				break
	print(ans)
resolve()

Solution (Python):
N,M=map(int,input().split())
A=list(input() for _ in range(N))
B=list(input() for _ in range(M))
ans="No"
for y in range(N-M+1):
    for x in range(N-M+1):
        if A[y][x:x+M]==B[0]:
            cond=True
            for i in range(M):
                if A[y+i][x:x+M]!=B[i]:
                    cond=False
                    break
            if cond:
                ans="Yes"
                break
    if ans=="Yes":
        break
print(ans)

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    A = [list(input()) for _ in range(n)]
    B = [list(input()) for _ in range(m)]

    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:
                print("Yes")
                exit()
    else:
        print("No")


if __name__ == '__main__':
    resolve()

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

bl_left_top=bl[0][0]

ans=0
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if al[i+k][j:j+m]!=bl[k]:
                break
            if k==m-1:
                ans=1
    if ans==1:
        break

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

Solution (Python):
n, m = map(int, input().split())
aaa = [input() for _ in range(n)]
bbb = [input() for _ 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 aaa[i + k][j + l] != bbb[k][l]:
                    flag = False
        if flag:
            ans = True
if ans:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np

N,M = map(int,input().split())

fig = []
for i in range(N):
  fig.append(list(input()))
fig = np.array(fig)
fig=np.where(fig ==".", 0, fig)
fig=np.where(fig =="
fig=fig.astype("int32")

template = []
for i in range(M):
  template.append(list(input()))
template = np.array(template)
template=np.where(template ==".", 0, template)
template=np.where(template =="
template=template.astype("int32")

F = False
for i in range(fig.shape[0]-template.shape[0]+1):
  for j in range(fig.shape[1]-template.shape[1]+1):
    F = F|np.allclose(fig[i:i+template.shape[0],j:j+template.shape[1]] , template)

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

Solution (Python):
def judge(h, w):
    for i in range(b_h):
        for j in range(b_w):
            b_element = B[i][j]
            a_element = A[i+h][w+j]
            if a_element != b_element:
                return False
    return True

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

a_h, a_w = N, len(A[0])
b_h, b_w = M, len(B[0])
max_h, max_w = a_h - b_h, a_w - b_w
ans = "No"

for i in range(a_h):
    for j in range(a_w):
        if j > max_w or i > max_h:
            continue
        if judge(i, j):
            ans = "Yes"

print(ans)