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 = []
for i in range(n):
    a.append(list(input()))
b = []
for i in range(m):
    b.append(list(input()))
wa = len(a[0])
wb = len(b[0])


ans = 'No'


for i in range(n-m+1):
    for j in range(wa-wb+1):
        flg = True
        for k in range(m):
            for l in range(wb):
                

                if a[i+k][j+l] != b[k][l]:
                    flg = False
        if flg == True:
            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)]
b=''
a='no'
for i in range(M):
    b+=B[i]
for i in range(N-M+1):
    if B[0]in A[i] :
        for j in range(N-M+1):
            a=''
            for k in range(M):
                a+=A[i+k][j:j+M]
            if a==b:
                print("Yes")
                exit()
print("No")

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

flag=0
for i in range(N-M+1):
    for j in range(N-M+1):
        A_tmp = A[i:i+M,j:j+M]
        
        
        if (B==A_tmp).all():
            flag=1
        if flag==1:
            break
    if flag==1:
        break
if flag==1:
    print("Yes")
else:
    print("No")

Solution (Python):











mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    n,m = map(int,input().split())
    a = [0] * n
    for i in range(n):
        a[i] = list(input())
    b = [0] * m
    for i in range(m):
        b[i] = list(input())
    if n==m:
        for i in range(n):
            for j in range(n):
                if a[i][j]!=b[i][j]:
                    print("No")
                    return
        print("Yes")
        return
    for i in range(n-m):
        for j in range(n-m):
            tmp = True
            for k in range(m):
                for l in range(m):
                    if a[i+k][j+l]!=b[k][l]:
                        tmp = False
                        break
                if not tmp:
                    break
            if tmp:
                print("Yes")
                return
    print("No")
    return

if __name__=='__main__':
    main()

Solution (Python):





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

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

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

if n == 1:
    if a[0] == b[0]:
        print('Yes')
    else:
        print('No')
    exit()

for sx in range(n-m):
    for sy in range(n-m):
        chk = True
        for tx in range(m):
            for ty in range(m):
                
                if a[sx+tx][sy+ty] == b[tx][ty]:
                    pass
                else:
                    chk = False
        if chk:
            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)]

if n == m:
    if a == b:
        print('Yes')
    else:
        print('No')
    exit()

for i in range(n-m+1):
    for j in range(n-m+1):
        c = [l[j:j+m] for l in a[i:i+m]]
        if c == b:
            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)]

res=False
for dh in range(N-M+1):
    for dw in range(N-M+1):
        tres=True
        for h in range(M):
            for w in range(M):
                if B[h][w]!=A[h+dh][w+dw]:
                    tres=False
        res|=tres
print("Yes"if res else "No")

Solution (Python):
import sys
from io import StringIO
import unittest

doTest=0

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    a=[]
    b=[]
    n,m=list(map(int, readline().strip().split()))
    for _ in range(n):
        a.append(readline().strip())
    for _ in range(m):
        b.append(readline().strip())

    hikaku=""
    for one in b:
        hikaku += one

    
    
    for i in range(n-m+1):
        for j in range(n-m+1):
            tmp=""
            for k in range(m):
                tmp+=str(a[j+k])[i:i+m]
            if tmp==hikaku:
                print("Yes")
                return
    print("No")

    return

if doTest==0:
    resolve()
    sys.exit()

Solution (Python):
import sys

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

A = [list(sys.stdin.readline()) for i in range(N)]

B = [list(sys.stdin.readline()) for i in range(M)]

for x in range(N-M+1):
    for y in range(N-M+1):
        flag = 0
        for i in range(M):
            for j in range(M):
                if A[x+i][y+j] != B[i][j]:
                    flag = 1
        if flag == 0:
            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)]
check = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        tmp_check = True
        for k in range(m):
            for l in range(m):
                if not (a[i + k][j + l] == b[k][l]):
                    tmp_check = False
        check = check or tmp_check
print("Yes" if check else "No")

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

a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
ans = False
for h in range(n-m+1):
  for w in range(n-m+1):
    flag = 1
    for i in range(m):
      for j in range(m):
        if a[h+i][w+j] != b[i][j]:
          flag = 0
          break
    if flag == 1:
      ans = True
      break
print("Yes" if ans else "No")

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

Solution (Python):


N, M = map(int, input().split())
A_list = []
for n in range(N):
    a = input()
    A_list.append(a)

B_list = []
for m in range(M):
    b = input()
    B_list.append(b)

diff = N - m

for i in range(diff):
    is_same = False
    for j in range(diff):
        for b in range(M):
            if B_list[b] == A_list[i + b][j: j + M]:
                is_same = True
            else:
                is_same = False
                break

        if is_same:
            print('Yes')
            exit()

    else:
        continue

print('No')

Solution (Python):
from sys import stdin
def main():
    readline=stdin.readline
    N,M=map(int,readline().split())
    A=[]
    for i in range(N):
        s=readline().strip()
        A.append(s)
    B=[]
    for i in range(M):
        s=readline().strip()
        B.append(s)
    
    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 B[k][l]!=A[k+i][l+j]:
                        flag=False
                        break
                if flag==False:
                    break
            if flag:
                break
        if flag:
            break
    if flag:
        print("Yes")
    else:
        print("No")
        
if __name__=="__main__":
    main()

Solution (Python):
listA = []
listB = []
N, M = map(int, input().split())
for a in range(N):
    A = input()
    listA.append(A)
for b in range(M):
    B = input()
    listB.append(B)
kazu = N - M
answer=[]
number=0
suuji=0

while number<=kazu:
    for z in range(0, kazu + 1):
        count=0
        for y in range(0, M):
            for x in range(0, M):
                if listA[z + y][x+number]==listB[y][x]:
                    count+=1
        answer.append(count)
    number+=1
for v in answer:
    if v==M**2:
        print('Yes')
        break
    else:
        suuji+=1
if suuji==len(answer):
    print('No')

Solution (Python):
from pprint import pprint
n,m = map(int, input().split())
a = list()
for i in range(n):
    a.append(input())
b = list()
for i in range(m):
    b.append(input())
a_len = len(a[0])
b_len = len(b[0])
for i in range(a_len-b_len+1):
    for j in range(n-m+1):
        check = True
        for k in range(m):
            if a[k+j][i:i+b_len] == b[k]:
                pass
            else:
                check = False
                break
        if check == True:
            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)]
x = 0
for i in range(n - m + 1):
    for j in range(n - m + 1):
        c = 0
        for k in range(m):
            for l in range(m):
                if a[i + k][j + l] == b[k][l]:
                    c += 1
        if c == m ** 2:
            x = 1
            break
    if x == 1:
        break
if x == 1:
    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)]
flag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if a[j+k][i:i+m]!=b[k]:
                break
        else:
            flag = 1
print("Yes" if flag else "No")

Solution (Python):
line = input().split(' ')
N,M = int(line[0]),int(line[1])
A = []
B = []
exe = 0
for i in range(N):
  A.append(input())
for i in range(M):
  B.append(input())
for i in range(N-M+1):
  f = 0
  for j in range(N-M+1):
    if A[i][j:j+M] == B[0]:
      f = 1
      for k in range(M):
        if not A[i+k][j:j+M] == B[k]:
          f = 0
          break
    if f == 1:
      exe = 1
if exe == 0:
  print("No")
else:
  print("Yes")

Solution (Python):

def check(A: list, B: list, start: (int, int)) -> bool:
    B_len = len(B)
    for b_pos_y, a_pos_y in enumerate(range(start[0], start[0]+B_len)):
        for b_pos_x, a_pos_x in enumerate(range(start[1], start[1]+B_len)):
            
            if A[a_pos_y][a_pos_x] != B[b_pos_y][b_pos_x]:
                return False
    return True



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

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

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

scope = N - M + 1

possible = False
for i in range(scope):
    for j in range(scope):
        if check(A, B, (i, j)) == True:
            possible = True
            break

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

Solution (Python):

import re
import sys

N,M = list(map(int, input().rstrip().split()))
A_list = [input().strip() for _ in range(N)]
B_list = [input().strip() for _ in range(M)]


candidate=[]   
for ia in range(N):
    find_string = [m.start() for m in re.finditer( B_list[0] , A_list[ia])]
    
    if find_string != [] and N-ia >= M:
        candidate.append( [ia,find_string] )

if candidate == []:
    print("No")
    sys.exit()

for start_r,start_c_list in candidate:
    for start_c in start_c_list:
    
        for ib in range(M):
            if B_list[ib] ==  A_list[start_r + ib][start_c:(start_c + M)]:
                if ib == (M-1):
                    print("Yes")
                    sys.exit()
                else:
                    continue
            else:
                break

else:
    print("No")

Solution (Python):


import re
import sys


N,M = list(map(int, input().rstrip().split()))
A_list = [input().strip() for _ in range(N)]
B_list = [input().strip() for _ in range(M)]






candidate=[]   
for ia in range(N):
    
    find_string = [m.start() for m in re.finditer( B_list[0] , A_list[ia])]
    
    
    
    if find_string != [] and N-ia >= M:
        candidate.append( [ia,find_string] )



if candidate == []:
    print("No")
    
    sys.exit()

check_column=""

for start_r,start_c_list in candidate:
    for start_c in start_c_list:
    
        for ib in range(M):
            

            
            if B_list[ib] ==  A_list[start_r + ib][start_c:(start_c + M)]:
                if ib == (M-1):
                    print("Yes")
                    sys.exit()
                else:
                    continue
            else:
                
                break

else:
    print("No")

Solution (Python):
import sys


def main():
    N,M = map(int,input().split())
    sa = [list(str(input())) for _ in range(N)]
    sb = [list(str(input())) for _ in range(M)]
    
    ans = False
    for i in range(N-M+1):
        for j in range(N-M+1):
            if sa[i][j] == sb[0][0]:
                count = 0
                for k in range(M):
                    for l in range(M):
                        if sa[i+k][j+l] == sb[k][l]:
                            count += 1
                if count == M**2:
                    ans = True
    
    if ans:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Solution (Python):


import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


from itertools import product
N, M = read_ints()
A = []
for a in read_map(N):
    for aa in a:
        A.append(1 if aa == '
B = []
for b in read_map(M):
    for bb in b:
        B.append(1 if bb == '



import numpy as np
A = np.array(A).reshape((N, N))
B = np.array(B).reshape((M, M))

for i, j in product(range(N - M + 1), range(N - M + 1)):
    ii, jj = i + M, j + M
    A_sub = A[i:ii, j:jj]
    if np.logical_xor(A_sub, B).sum() == 0:
        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)])

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

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

for i in range(n-m+1):
  for j in range(n-m+1):
    c =0
    for k in range(m):
      for l in range(m):
        if a[i+k][j+l] == b[k][l]:
          c +=1
          
          
    
    if c == m**2:
      print("Yes")
      exit()
      
      
      
print("No")

Solution (Python):
n,m = map(int,input().split())
N = [list(list(input())) for _ in range(n)]
M = [list(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):
            if N[i+k][j:j+m] != M[k]:
                break
        else:
            print('Yes')
            exit()
else:
    print('No')

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

M = [list(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):
            
            
            if N[i+k][j:j+m] != M[k]:
                break
        else:
            print('Yes')
            exit()
    
else:
    print('No')

Solution (Python):

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

flg=False
for i in range(n-m+1):
    for j in range(n-m+1):
        if all([b[l]==a[i+l][j:(j+m)] for l in range(m)]):
            flg=True
            break

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

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

hasFound = False
search = N-M+1
for y in range(search):
    for x in range(search):
        if hasFound: break
        for h in range(M):
            src = A[y+h][x:x+M]
            dst = B[h]
            if dst != src:
                break
        else:
            hasFound = True


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

Solution (Python):

import sys
try:
    from typing import List
except ImportError:
    pass

YES = "Yes"  
NO = "No"  


def solve(N: int, M: int, A: "List[str]", B: "List[str]"):
    print(YES if any(all(
        A[y + dy][x + dx] == B[dy][dx]
        for dx in range(M) for dy in range(M)
    ) for x in range(N - M + 1) for y in range(N - M + 1)) else NO)


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


if __name__ == '__main__':
    main()

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

Diff = N - M + 1
if Diff == 1 :
    if A == B :
        print("Yes")
    else :
        print("No")
    exit()

def partofA(i, j) :
    Ans = []
    for x in range(M) :
        Ansx = []
        for y in range(M) :
            Ansx.append(A[x+i][y+j])
        Ans.append(Ansx)
    return Ans

for i in range(Diff) :
    for j in range(Diff) :
        if partofA(i,j) == B :
            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):
        cnt = 0
        for k in a[i:i+m]:
            if not k[j:j+m]==b[cnt]:
                break
            cnt += 1
        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)]
judge=any([line[j:j+M] for line in A[i:i+M]]==B for i in range(N-M+1) for j in range(N-M+1))
print("Yes" if judge 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))

ans = 'No'
for i in range(n-m+1): 
  for j in range(n-m+1):
    if b[0] == a[i][j:j+m]:
      for x in range(1,m):
        if b[x] != a[i+x][j:j+m]:
          break
      else:
        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))
 

ans = 'No'
for i in range(n-m+1): 
  for j in range(n-m+1): 
    
    if b[0] == a[i][j:j+m]:
      
      for x in range(1,m):
        if b[x] != a[i+x][j:j+m]:
          break
      else:
        ans = 'Yes'
  
 
print(ans)

Solution (Python):
import sys
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
index = n - m + 1


def check(a, b):
    for u, v in zip(a, b):
        for i in range(m):
            if u[i] == v[i]:
                pass
            else:
                return False
    return True


for i in range(index):
    x = a[i:i + m]
    for j in range(index):
        r = []
        for w in x:
            y = w[j:j+m]
            r.append(y)
        if check(r, b):
            print("Yes")
            sys.exit()

print("No")

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

ans = "No"
for y in range(N-M+1):
    for x in range(N-M+1):
        same = True
        for dy in range(M):
            for dx in range(M):
                if n[y+dy][x+dx] != m[dy][dx]:
                    same = False
                    break
            if not same:
                break
        if same:
            ans = "Yes"
            break
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def ok(i,j):
        for ii in range(m):
            if aa[ii+i][j:j+m]!=bb[ii]:return False
        return True

    n,m=MI()
    aa=[[c=="
    bb=[[c=="
    for i in range(n-m+1):
        for j in range(n-m+1):
            if ok(i,j):
                print("Yes")
                exit()
    print("No")

main()

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

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

"""考え方
端から端まで、で一致するパターンがないか全探索
"""


A = []
for n in range(N):
  A.append(input())
B = []
for m in range(M):
  B.append(input())



ans = 'No'
for i in range(N-M+1): 
  for j in range(N-M+1): 
    
    if B[0] == A[i][j:j+M]:
      
      for x in range(1,M):
        if B[x] != A[i+x][j:j+M]:
          break
      else:
        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)]

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

for i in range(n-m+1):
    for j in range(n-m+1):
        if judge(i,j):
            print('Yes')
            exit()
print('No')

Solution (Python):
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,m = map(int,readline().split())
lst1 = []
for i in range(n):
    lst1.append(readline().rstrip().decode('utf-8'))

lst2 = []
for i in range(m):
    lst2.append(readline().rstrip().decode('utf-8'))

for i in range(n-m+1):
    for j in range(n-m+1):
        flag = 1
        for k in range(m):
            if lst1[i+k][j:j+m] != lst2[k]:
                flag = 0
        
        if flag:
            print("Yes")
            exit()
print("No")

Solution (Python):
def main():
    img_a_row, img_b_row = map(int, input().split())
    img_a = [input() for _ in range(img_a_row)]
    img_b = [input() for _ in range(img_b_row)]
    answer = False
    for i in range(img_a_row - img_b_row + 1):
        for j in range(img_a_row - img_b_row + 1):
            count = 0
            for k in range(img_b_row):
                if img_a[i + k][j:j+img_b_row] == img_b[k]:
                    count += 1
            if count == img_b_row:
                answer = True
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()

Solution (Python):
import sys
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):
        A = [a[s][i:i+m] for s in range(j,j+m)]
        if A == b:
            print("Yes")
            sys.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)]
inc=0
for i in range(N-M+1):
    for j in range(N-M+1):
        if(B[0]==A[i][j:j+M]):
            t=1
            for k in range(1,M):
                if(B[k]!=A[i+k][j:j+M]):
                    t=0
            if(t==1):
                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())

ans = False
for iy in range(0, n-m+1):
  if ans:
    break
  for ix in range(0, n-m+1):
    tmp = True
    for y in range(0, m):
      for x in range(0, m):
        if A[iy+y][ix+x] != B[y][x]:
          tmp = False
    if tmp:
      ans = tmp
      break
      
if ans:
  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)]

si, sj = 0, 0
c = 0
while si <= n - m:
    ni, nj = si, sj
    rest = m ** 2
    for i in range(m):
        nj = sj
        for j in range(m):
            
            if a[ni][nj] != b[i][j]:
                break
            nj +=1
            rest -= 1
        ni += 1
        
    if rest == 0:
        print("Yes")
        exit()
    sj += 1
    if sj > n - m:
        si += 1
        sj = 0

print("No")

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

    for i in range(N):
        B.append(input().split()[0])

    for _ in range(M):
        A.append(input().split()[0])

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

main()

Solution (Python):


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

c = False
exist = False

for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j] == b[0][0]:
            c = True
            for k in range(m):
                for l in range(m):
                    if a[i+k][j+l] != b[k][l]:
                        c = False
            if c:
                exist = True

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

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

la = [list(input()) for i in range(n)]
lb = [list(input()) for i in range(m)]
c = 0
t = False

for i in range(n-m+1):
    for j in range(n-m+1):
        if la[i][j] == lb[0][0]:
            t = True
            for k in range(m):
                for l in range(m):
                    if la[i+k][j+l] != lb[k][l]:
                        t = False
                        break
                if t == False:
                    break
            if t == True:
                break
        if t == True:
            break
    if t == True:
        break

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

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

for i in range(n-m+1):
    for j in range(n-m+1):
        tmp=1
        for k in range(m):
            for l in range(m):
                
                if a[i+k][j+l]!=b[k][l]:
                    tmp=0
        if tmp==1:
            print("Yes")
            quit()
print("No")

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

mm = [input() for _ in range(M)]
nn = [input() for _ in range(N)]
ans = False
for i in range(M - N + 1):
    if (ans == True):
        break
    for j in range(M - N + 1):
        if (ans == True):
            break
        x = []
        temp = mm[j:j + N]
        for k in range(N):
            temp2 = temp[k]
            x.append(temp2[i:i + N])
            
        if (x == nn):
            ans = True

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

            if not flag:
                break

        if flag:
            break

    if flag:
        break

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