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

hidariue = b[0][0]
hasikouho = []
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j] == hidariue:
            hasikouho.append([i,j])

x = []

for v in hasikouho:
    ans = "Yes"
    i = int(v[0])
    j = int(v[1])
    for p in range(m):
        if ans == "Yes":
            for q in range(m):
                if a[i+p][j+q] != b[p][q]:
                    ans = "No"
                    break
        else:
            break
    x.append(ans)

if "Yes" in x:
    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):
        AND = True
        for k in range(M):
            judge = A[i+k][j:j+M] == B[k][0:M]
            AND &= judge
        if AND:
            print('Yes')
            exit()

print('No')

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

A = []
for i in range(N):
    tmp = input()
    A.append([0 if s=="." else 1 for s in tmp])
B = []
for i in range(M):
    tmp = input()
    B.append([0 if s=="." else 1 for s in tmp])
    
A = np.array(A)
B = np.array(B)

def is_match(a, b):
    return (a==b).all()
flag = False
for i in range(N):
    for j in range(N):
        x_left = i
        x_right = i + M
        y_up = j
        y_under = j + M
        if x_right > N or y_under > N:
            continue
        if is_match(B, A[x_left:x_right, y_up:y_under]):
            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)]
flag = False
for i in range(n):
    for j in range(n):
        for k in range(m):
            for l in range(m):
                if i + k >= n or j + l >= n:
                    flag = True
                    break
                if a[i + k][j + l] != b[k][l]:
                    flag = True
                    break
            if flag:
                flag = False
                break
            if k == m - 1:
                print('Yes')
                exit()
print('No')

Solution (Python):
import numpy as np
import sys

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

flag = False

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

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

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

class Image:
    def __init__(self, n):
        self.matrix = [list(input()) for _ in range(n)]
        self.n = n

    def isIncluded(self, a):
        for i in range(a.n-self.n+1):
            for j in range(a.n-self.n+1):
                template = [row[j:j+self.n] for row in a.matrix[i:i+self.n]]
                if template == self.matrix:
                    return True
        return False


a = Image(n)
b = Image(m)

print("Yes" if b.isIncluded(a) else "No")

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

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

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()))
ans = 'No'
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:
            ans = 'Yes'
print(ans)

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

Solution (Python):
import sys
import numpy as np

n, m = map(int, sys.stdin.readline().split())
A = np.array([list(sys.stdin.readline().rstrip()) for _ in range(n)], dtype='U1')
B = np.array([list(sys.stdin.readline().rstrip()) for _ in range(m)], dtype='U1')

def main():
    
    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):
                return 'Yes'
    return 'No'

if __name__ == '__main__':
    ans = main()
    print(ans)

Solution (Python):
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
a_ls = []
b_ls = []
for i in range(n):
    a_ls.append(sys.stdin.readline().strip())
for i in range(m):
    b_ls.append(sys.stdin.readline().strip())

def matching(a, b, size, start):
    start_y, start_x = start
    flg = True
    for i in range(size):
        for j in range(size):
            flg &= a[start_y + i][start_x + j] == b[i][j]
            if not flg:
                return flg
    return flg

res = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        res |= matching(a_ls, b_ls, m, (i, j))
        if res:
            break
    if res:
        break
print("Yes" if res 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):
        window = [x[i:i+m] for x in a[j:j+m]]
        if window == b:
            print('Yes')
            quit()
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="No"
for i in range(n-m+1):
	for j in range(n-m+1):
		check=0
		for k in range(m):
			for l in range(m):
				if b[k][l]==a[i+k][j+l]:
					check+=1
					if check==m*m:
						ans="Yes"
				else:
					break
			else:
				continue
			break
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)]

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):
import numpy as np
n, m = map(int, input().split())
a = [[j for j in input()] for i in range(n)]
b = [[j for j in input()] for i in range(m)]
ans = 'No'
na = np.array(a)
nb = np.array(b)
for i in range(n-m+1):
    for j in range(n-m+1):
        s = na[i:m+i, range(j, m+j)]
        if (s == nb).all():
            ans = 'Yes'
            break
print(ans)

Solution (Python):
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for j in range(M)]
u = 0
for i in range(N - M + 1):
  for j in range(N - M + 1):
    s = 0
    for k in range(M):
      for l in range(M):
        if A[i+k][j+l] != B[k][l]:
          s += 1
    if s == 0:
      u = 1
if u == 1:
  print('Yes')
elif u == 0:
  print('No')

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

for idx1 in range(N - M + 1):
    lst_j = [x for x in lst_n[idx1 : idx1 + M]]
    for idx2 in range(N - M + 1):
        lst_k = [y[idx2 : idx2 + M] for y in lst_j]
        if lst_k == lst_m:
            print("Yes")
            exit()
print("No")

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,m=nl()
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(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:
            print('Yes')
            exit()
print('No')

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

for i in range(N - M + 1):
    for j in range(N - M + 1):
        if [A[i + k][j:j + M] for k in range(M)] == B:
            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)]

ans = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        
        f = True
        for x in range(m):
            for y in range(m):
                if a[x + i][y + j] != b[x][y]:
                    f = False

        if f:
            ans = True

if ans:
    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)]
ans = "No"
for i in range(n - m + 1):
  for j in range(n - m + 1):
    S = []
    for k in range(m):
      S.append(A[i + k][j:j + m])
      if S == B:
        ans = "Yes"
print(ans)

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

ans = "No"
flag = False

for i in range(n-m+1):
    for j in range(n-m+1):
        if b[0][0] == a[i][j]:
            atmp = []
            atmp.extend([a[s][j:j+m] for s in range(i,i+m)])
            if b == atmp:
                ans = "Yes"
                flag = True
        if flag:
            break
    if flag:
        break

print(ans)

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

def dfs(x: int, y: int, i: int, j: int) -> bool:
    if i-x == m:
        return True
    if j-y == m:
        return True

    if a[i][j] != b[i-x][j-y]:
        return False

    if not dfs(x, y, i, j+1):
        return False
    if not dfs(x, y, i+1, j):
        return False
    if not dfs(x, y, i+1, j+1):
        return False

    return True

ans = "No"
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j] == b[0][0]:
            x = i
            y = j
            if dfs(x, y, i, j):
                ans = "Yes"
                break

print(ans)

Solution (Python):
n,m=map(int,input().split())
nn=""
mm=[]
for i in range(n):
    nn+=input()+"\n"
for i in range(m):
    mm.append(input()+"\n")
count=0
for i in range(m):
    if(mm[i] in nn ):
        count+=1

if(count==m):
    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 y in range(n-m+1):
    for x in range(n-m+1):
        f=1
        for i in range(m):
            for j in range(m):
                if a[i+x][j+y]!=b[i][j]:
                    f=0
        if f:
            print("Yes")
            exit()
print("No")

Solution (Python):
import sys
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):
    temp=input()
    temp=temp.replace('.',"0")
    temp=temp.replace('
    A[i] = list(map(int,list(temp)))
for i in range(M):
    temp=input()
    temp=temp.replace('.',"0")
    temp=temp.replace('
    B[i] = list(map(int,list(temp)))

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

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

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

ans = "Yes"
for a in A:
    for b in B:
        if b not in a:
            ans = "No"
print(ans)

Solution (Python):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
row = 0
column = 0
flg = True
while True:
    flg = True
    if N < M+column:
        break
    row = 0
    while True:
        flg = True
        if N < M+row:
            break
        for i in range(M):
            for k in range(M):
                if B[i][k] != A[i+column][k+row]:
                    flg = False
                    break
        if flg:
            print('Yes')
            exit()
        row += 1
    column += 1
print('No')

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

for i in range(n - m + 1):
    for j in range(n - m + 1):
        a = True
        for k in range(m):
            if lstn[i + k][j : j + m] != lstm[k]:
                a = False
                break
        if a:
            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)]
ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(i,i+M):
      for l in range(j,j+M):
        if A[k][l] != B[k-i][l-j]:
          break
        if A[k][l] == B[k-i][l-j] and k == i+M-1 and l == j+M-1:
          ans = 1
      else:
        continue
      break

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

Solution (Python):
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]

li = [["" for i in range(n)]for j in range(n)]
for i in range(n):
    s = stdin.readline().rstrip()
    for j in range(n):
        li[i][j] = s[j]

lin = [["" for i in range(m)]for j in range(m)]
for i in range(m):
    s = stdin.readline().rstrip()
    for j in range(m):
        lin[i][j] = s[j]

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

Solution (Python):
import numpy as np

N, M = map(int, input().split())
A = []
for i in range(N):
    S = input()
    A.append([S[i] for i in range(len(S))])
A = np.array(A)
B = []
for i in range(M):
    S = input()
    B.append([S[i] for i in range(len(S))])
for i_raw in range(N - M + 1):
    for j_col in range(N - M + 1):
        if (A[i_raw : i_raw + M, j_col : j_col + M] == B).all():
            print("Yes")
            exit()
print("No")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(N: int, M: int, A: "List[str]", B: "List[str]"):
    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]:
                        continue
                    else:
                        break
                else:
                    continue
                break    
            else:
                print(YES)
                return

    print(NO)    
    return


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):
import sys
if sys.platform == 'ios':
	sys.stdin = open('input_file.txt')
	

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

a = [str(input()) for i in range(n)]
b = [str(input()) for i in range(m)]

s = [ [0]*m for i in range(m) ]

ans = 0

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

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

Solution (Python):
N,M=map(int,input().split())
import numpy as np
A=np.array([list(input()) for _ in range(N)])
B=np.array([list(input()) for _ in range(M)])
ans='No'
for i in range(N-M+1):
  for j in range(N-M+1):
    if (A[i:i+M,j:j+M]==B).all():
      ans='Yes'
      break
  else:continue
  break
    
    
print(ans)

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

area_a = []
for i in range(n):
    array = input()
    area_a.append(array)

area_b = []
for i in range(m):
    array = input()
    area_b.append(array)

def check(i, j):
    flag = True
    for u in range(m):
        x = area_a[i+u][j:j+m]
        if x != area_b[u][:]:
            flag = False
            break
        else:
            continue
    if flag is True:
        print('Yes')
        exit()

for i in range(n-m+1):
    for j in range(n-m+1):
        check(i,j)

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):
        c = 0
        for x in range(M):
            if A[x + i][j:j + M] == B[x]:
                c += 1
        if c == M:
            ans = "Yes"
            break
    else:
        continue
    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 i in range(N - M + 1):
    for j in range(N - M + 1):
        c = 0
        for x in range(M):
            for y in range(M):
                if A[x + i][y + j] == B[x][y]:
                    c += 1
        if c == M ** 2:
            ans = "Yes"
            break

print(ans)

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




ba = []
for i in range(n):
    ba.append(input())
bb = []
for i in range(m):
    bb.append(input())
    

 
for i in range(n-m+1):
    for j in range(n-m+1):
        ok = True
        for k in range(m):
            
            if ba[i+k][j:j+m] != bb[k]:
                ok = False
                break
        if ok:
            print("Yes")
            exit()
print("No")

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

a = []
for _ in range(n):
    a.append(input())

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

for i in range(n - m + 1):
    for j in range(n - m + 1):
        flag = True
        for b_x in range(m):
            a_x = b_x + i
            for b_y in range(m):
                a_y = b_y + j
                if(a[a_x][a_y] != b[b_x][b_y]):
                    flag = False
        if flag == True :
            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())

def CheckExist(ai, aj):
    for bi in range(M):
        for bj in range(M):
            if A[ai+bi][aj+bj] != B[bi][bj]:
                return False
    return True

for ai in range(N - M + 1):
    for aj in range(N - M + 1):
        if CheckExist(ai, aj):
            print('Yes')
            exit(0)
print('No')

Solution (Python):
N,M=map(int,input().split())
gridA=[None]*N
gridB=[None]*M
for i in range(N):
  gridA[i]=input()
for i in range(M):
  gridB[i]=input()

def isMatch(y,x):
  for i in range(M):
    for j in range(M):
      if gridB[i][j]!=gridA[y+i][x+j]:
        return False
  return True

for i in range(N-M+1):
  for j in range(N-M+1):
    if isMatch(i,j):
      print("Yes")
      exit(0)
print("No")

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

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


num = n - m + 1


check = 'No'


for i in range(num):
    for j in range(num):
        C = []
        
        for k in range(m):
            
            C.append(A[i+k][j:j+m])
        
        if C == B:
            check = 'Yes'
            break
print(check)

Solution (Python):
import numpy as np

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

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

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

A=np.asarray(A)
B=np.asarray(B)
flg=False

  
for x in range(N-M):
    for y in range(N-M):
        if (A[x:x+M,y:y+M] == B).all():
            flg=True
if flg:
    print("Yes")
else:
    try:
        if (A == B).all():
            print("Yes")
        else:
            print("No")
    except:
        print("No")

Solution (Python):
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ 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())
S = [input() for _ in range(N)]
T = [input() for _ in range(M)]
ans = False
cnt = N - M
for i in range(cnt+1):
    for j in range(cnt + 1):
        tmp = T[0]
        check = S[i][j:M+j]
        key = 0
        if(check == tmp):
            key += 1
            for k in range(1,M):
                tmp = T[k]
                check =  S[i+k][j:M+j]
                if(check == tmp):
                    key += 1
        if(key == M):
            ans =True
            break

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

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

ans='No'
cnt=0
for i in range(n-m+1):
    for j in range(n-m+1):
        for i1 in range(m):
            for j1 in range(m):
                if b[i1][j1]==a[i+i1][j+j1]:
                    cnt+=1
        
        if cnt==m**2:
            ans='Yes'
            cnt=0
        else:
            cnt=0
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 i in range(n-m+1):
    for j in range(n-m+1):
        C=[a[i+k][j:j+m] for k in range(m)] 
        if C==b:
            ans="Yes"

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

print(ans)

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

def subdata(a, i, j):
  return [row[j:j + m] for row in a[i:i + m]]

def template_matching(a, b):
  for i in range(n - m + 1):
    for j in range(n - m + 1):
      if subdata(a, i, j) == b:
        return "Yes"
  return "No"

print(template_matching([input() for _ in range(n)], [input() for _ in range(m)]))

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

flag=False
cnt=0
for a_i in range(n-m+1):
    for a_j in range(n-m+1):
        for b_i in range(m):
            if a[a_i+b_i][a_j:a_j+m]==b[b_i]:
                cnt+=1
        if cnt==m:
            flag=True
            break
        cnt=0
print('Yes' if flag else 'No')

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

def check(w,h):
    if w+M>N or h+M>N:
        return False
    List=[A[j][w:w+M] for j in range(h,h+M)]
    return (List==B)

ans=0
for i in range(N):
    for k in range(N):
        ans+=check(i,k)

print(['No','Yes'][ans>=1])

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M = MI()
    A=tuple((ST()) for _ in range(N))
    B=tuple((ST()) for _ in range(M))

    for i in range(N-M+1):
        for j in range(N-M+1):
            
            ok = True
            for k in range(M):
                if A[i+k][j:j+M] != B[k][:]:
                    ok=False

            if ok:
                print("Yes")
                exit()
    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)]
r=any([r[j:j+m] for r in a[i:i+m]]==b for i in range (n-m+1) for j in range(n-m+1))
print("Yes" if r else "No")

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

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

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


num = n - m + 1
check = 0


for i in range(num):
    for j in range(num):
        C = []
        
        for k in range(m):
            C.append(A[i+k][j:j+m])
        if C == B:
            check += 1

if check >= 1:
    print('Yes')
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):
		ans = "Yes"
		for k in range(m):
			sA = A[i+k][j:j+m]
			sB = B[k]
			
			if sA != sB:
				ans = "No"
				break
		if ans == 'Yes':
			break
	if ans == "Yes":
		break
print(ans)

Solution (Python):
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def is_match(parent, child, pi, pj):
    for ci in range(len(child)):
        for cj in range(len(child[ci])):
            
            
            if child[ci][cj] != parent[pi+ci][pj+cj]:
                return False
    return True


def solve(N, M, inputs):
    map_parent = list(map(list, inputs[:N]))
    map_child = list(map(list, inputs[N:]))

    for pi in range(0, N-M+1):
        for pj in range(0, N-M+1):
            if is_match(map_parent, map_child, pi, pj):
                return 'Yes'
    return 'No'


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(N+M))
    print(ret)

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

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

b_index = 0
for i in range(N):
    for j in range(len(A[i])):
        if A[i][j] == B[0][0]:
            for i2 in range(M):
                for j2 in range(len(B[i2])):
                    if i+i2 > N-1 or j+j2 > len(A[i+i2])-1:
                        break
                    elif A[i+i2][j+j2] != B[i2][j2]:
                        break
                else:
                    continue
                break
            else:
                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)])

judge = False

for i in range(n - m + 1):
    for j in range(n - m +1):
        image = a[i:i+m,j:j+m]
        if (image == b).all(): 
            judge = True

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



flag = False

for i in range(n - m + 1):
    for j in range(n - m + 1):
        mat = a[i : i + m, j : j + m]
        
        if (mat == b).all():
            flag = True

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

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

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

SUM=0
for i in range(M):
    for j in range(M):
        if(B[i][j]=="
            SUM+=1

for k in range(N):
    t=0
    for i in range(M):
        if(A[k][i]=="
            t+=1
    C[k][i-M+1]=t
    for i in range(M,N):
        if(A[k][i]=="
            t+=1
        if(A[k][i-M]=="
            t-=1
        C[k][i-M+1]=t
for i in range(N):
    for j in range(N-M+1):
        for k in range(M):
            D[j][i]+=C[j+k][i]

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