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())
pic = [list(input()) for _ in range(N)]
template = [list(input()) for _ in range(M)]

'''
for _ in pic:
    print("".join(_))

for _ in template:
    print("".join(_))
'''


def ifIncluded(start_position, pic, template):
    for t in range(M):
        for y in range(M):
            if not template[t][y] == pic[start_position[0] + t][start_position[1]+y]:
                return False
    return True


for t in range(N - M+1):
    for y in range(N - M+1):
        start_position = [t, y]
        if ifIncluded(start_position, pic, template):
            print('Yes')
            exit()
print('No')

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

Solution (Python):
N,M=map(int,input().split())
A=[input() for i in range(N)]
B=[input() for j in range(M)]
for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:j+M]==B[0]:
            if all(A[i+k][j:j+M]==B[k] for k in range(1,M)):
                print("Yes")
                exit()
print("No")

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7



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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7



N, M = MAP()
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):  
		tmp_lis = []
		for k in range(M):
			tmp_lis.append(A[i+k][j:j+M])
		if tmp_lis == B:
			print("Yes")
			exit()
else:
	print("No")

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

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

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

for g in range(n-m+1):
    for h in range(n-m+1):
        p=0
        for i in range(m):
            p+=a[g+i][h:h+m]==b[i]
        if p==m:
            print('Yes')
            exit()
print('No')

Solution (Python):

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

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

a = [list(map(str, input().rstrip())) for x in range(n)]
b = [list(map(str, input().rstrip())) for x in range(m)]

ans = []
for i in range(n - m + 1):
    for j in range(n - m + 1):
        tmp = []
        for x in range(m):
            for y in range(m):
                if a[i + x][j + y] == b[x][y]:
                    tmp.append(True)
                else:
                    tmp.append(False)
        ans.append(all(tmp))

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

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

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):
    C = []
    for k in range(M):
      C.append(A[j+ k][i:i+ M])
    if(B == C):
      print("Yes")
      flag = 1
      break
  if(flag == 1):
    break
else:
  print("No")

Solution (Python):

import sys
input = sys.stdin.readline









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

for dh in range(N-M+1):
    for dw in range(N-M+1):
        flg = True
        for h in range(M):
            for w in range(M):
                if B[h][w] != A[h+dh][w+dw]:
                    flg = False
                    break
        if flg:
            print("Yes")
            sys.exit()

print("No")

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
 
N, M = MAP()
 
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
 
if A == B:
	print("Yes")
	exit()

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N, M = MAP()

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

if A == B:
	print("Yes")
	exit()

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

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

print('No')

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

diff = n-m+1
include = False
for up_y in range(diff):
    for left_x in range(diff):
        same = True
        for y in range(up_y, up_y+m):
            for x in range(left_x,left_x+m):
                if small_image_ls[y-up_y][x-left_x] != big_image_ls[y][x]:
                    same = False
        if same:
            include = True
if include:
    print('Yes')
else:
    print('No')

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

for i in range(n - m + 1):
    for j in range(n - m + 1):
        check = [a[i + k][j:j + m] for k in range(m)]

        flag = True
        for x in range(m):
            if check[x] != b[x]:
                flag = False
                break

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

print('No')

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

for i in range(n-m+1):
    if not M[0] in N[i]:
        continue
    else:
        pos = N[i].index(M[0])
        flag = True
        for j in range(m):
            if M[j] != N[i+j][pos:pos+m]:
                flag = False
                break
        if flag:
            print("Yes")
            exit()
print("No")

Solution (Python):
N,M = map(int,input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for dx in range(N-M+1):
    for dy in range(N-M+1):
        flg = True
        for i in range(M):
          if A[i+dx][dy:dy+M] != B[i]:
            flg = False
            break
        if flg:
          print("Yes")
          exit()
print("No")

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

contain = False
for i in range(n-m+1):
    for j in range(n-m+1):
        ok = True
        for k in range(m):
            if not ok:
                break
            for l in range(m):
                if a_mat[i+k][j+l] != b_mat[k][l]:
                    ok = False
                    break
        if ok:
            contain = True
            break
if contain:
    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 dx in range(N-M+1):
    for dy in range(N-M+1):
        flg = True
        for i in range(M):
          if A[i+dx][dy:dy+M] != B[i]:
            flg = False
            break
        if flg:
          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 dx in range(N-M+1):
    for dy in range(N-M+1):
        flg = True
        for i in range(M):
            for j in range(M):
                if A[i+dx][j+dy] != B[i][j]:
                    flg = False
        if flg:
            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 = False
for dx in range(N-M+1):
    for dy in range(N-M+1):
        flg = True
        for i in range(M):
            for j in range(M):
                if A[i+dx][j+dy] != B[i][j]:
                    flg = False
        if flg:
            ans = True
print("Yes" if ans else "No")

Solution (Python):

import sys
n, m = map(int, input().split())
N = []
M = []
for i in range(n):
    N.append(input())
for i in range(m):
    M.append(input())

for i in range(n-m+1):
    if M[0] not in N[i]:
        continue
    else:
        ind = N[i].index(M[0])
        A = True
        for j in range(m):
            if M[j] != N[i+j][ind:ind+m]:
                A = False
                break
        if A:
            print("Yes")
            sys.exit()
print("No")

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

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


for i in range(n - m + 1):
    for j in range(n - m + 1):
        ok = True
        for k in range(m):
            if A[i + k][j:j + m] != B[k]:
                ok = False
                break
        if ok:
            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)]

ah = len(a)
aw = len(a[0])
bh = len(b)
bw = len(b[0])

for i in range(ah - bh + 1):
    for j in range(aw - bw + 1):
        tmp = []
        for k in range(bh):
            tmp.append(a[i + k][j : j + bw])
        if b == tmp:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")

Solution (Python):
def check(s,t):
    for i in range(s,s+M):
        for j in range(t,t+M):
            if A[i][j] != B[i-s][j-t]:
                return False
    return True


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):
        if check(i,j):
            print("Yes")
            exit()

print("No")

Solution (Python):

import sys

from math import log10, sqrt, ceil
def input(): return sys.stdin.readline()[:-1] 



def solve():
    
    n, m = [int(x) for x in input().split()]
    a = []
    for i in range(n):
        a.append(input())
    b = []
    for i in range(m):
        b.append(input())

    ok = 0
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            f = 1
            for x in range(m):
                for y in range(m):
                    if a[i+x][j+y] != b[x][y]:
                        f = 0
            ok |= f


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




t = 1

for case in range(1,t+1):
    ans = solve()



"""
1 -> (1, 2) -> (2 ** 3, 3) -> (3, 1)
100000007
"""

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    def compare(s_list, t_list):
        assert(len(s_list) == len(t_list))
        assert(len(s_list[0]) == len(t_list[0]))
        assert(len(s_list) == len(s_list[0]))
        size = len(s_list)
        for i in range(size):
            if s_list[i] != t_list[i]:
                return False
        return True

    def contain(A, B, n, m):
        diff = n - m
        for i in range(diff+1):
            for j in range(diff+1):
                new_A = [s[j:n-diff+j] for s in A[i:n-diff+i]]
                if compare(new_A, B):
                    return True
        return False


    n, m = mi()
    A = [input() for _ in range(n)]
    B = [input() for _ in range(m)]
    print('Yes') if contain(A, B, n, m) else print('No')


if __name__ == "__main__":
    main()

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

A_image = [input() for i in range(N)]
B_image = [input() for i in range(M)]
Flag = False

for i in range(N):
    for j in range(N): 
        if i + M <= N and j + M <= N:
            temp = []
            for k in range(M):
                temp.append(A_image[i+k][j : j+M])
            if temp == B_image:
                Flag = True

if Flag is True:
    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-m+1):
    
    for k in range(n-m+1):
        flag=True
        for j in range(i,i+m):
            
            
            if a[j][k:k+m]!=b[j-i]:
                flag = False
                break
        if flag:
            break
    if flag:
        break

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

Solution (Python):
from itertools import product
n, m = list(map(int, input().split()))
A = [list(input()) for _ in range(n)]
B = [list(input()) for _ in range(m)]
for i, j in product(range(n - m + 1), range(n - m + 1)):
    if all([A[i + k][j:j + m] == B[k] for k in range(m)]):
        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)]

def check():
    for i in range(n):
            for j in range(n):
                if i + m <= n and j + m <= n:
                    aa = []
                    for k in range(m):
                        aa.append(a[i + k][j : j+m])
                    if aa == b:
                        return 'Yes'
    return 'No'

print(check())

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

flag = True
for i in range(n):
    if flag:
        for j in range(n):
            if i + m <= n and j + m <= n:
                aa = []
                for k in range(m):
                    aa.append(a[i + k][j : j+m])
                if aa == b:
                    print('Yes')
                    flag = False
                    break

if flag:
        print('No')

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

def check(i, j, A, B, M):
    for k in range(M):
        if A[i+k][j:j+M] != B[k]:
            return False
    return True 

def Main(N, M, A, B):
    for i in range(N-M+1):
        for j in range(N-M+1):
            if A[i][j] == B[0][0]:
                if check(i, j, A, B, M):
                    return 'Yes'
    return "No"     
    
res = Main(N, M, A, B)
print(res)

Solution (Python):

n,m = map(int,input().split())
a_list = [input() for nesya in range(n)]
b = [input() for motsu in range(m)]


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


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

Solution (Python):
import numpy

n, m = map(int, input().split())
a = numpy.zeros([n, n], dtype=int)
b = numpy.zeros([m, m], dtype=int)
for i in range(n):
    s = input()
    for j in range(n):
        if s[j] == '
            a[i, j] = 1
for i in range(m):
    s = input()
    for j in range(m):
        if s[j] == '
            b[i, j] = 1
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if numpy.all(a[i: i + m, j: j + m] == b):
            print("Yes")
            exit()
print("No")

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def Yes(): print("Yes"); return
def No(): print("No"); return


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




N,M = inputIL()
n = inputSLs(N)
m = inputSLs(M)

for i in range(N-M+1):
  for j in range(N-M+1):
    if m == [ n[k][i:i+M] for k in range(j,j+M)]:
      Yes()
      exit()
No()

Solution (Python):
def sub(m, line, row, a, b):
    one_ans = "T"
    for j in range(1, m):
        a_match = a[line + j][row : row + m]
        
        if b[j] == a_match:
            one_ans += "T"
        else:
            one_ans += "F"
    return (one_ans)

def resolve_mine(): 
    n, m = map(int, input().split())
    
    a = list()
    for i in range(n):
        line = input()
        a.append(line)
    
    b = list()
    for i in range(m):
        line = input()
        b.append(line)
    
    ans = list()
    for a_line in range(n - m + 1):
        count = a[a_line].count(b[0])
        
        
        if count == 1:
            line, row = a_line, a[a_line].find(b[0])
            one_ans = sub(m, line, row, a, b)
            ans.append(one_ans)
        elif count > 1:
            line = a_line
            formar_row = -1
            for counter in range(count):
                formar_row = a[a_line].find(b[0], formar_row + 1)
                row = formar_row
                one_ans = sub(m, line, row, a, b)
                ans.append(one_ans)

    
    result = "No"
    for an in ans:
        if "T" * m == an:
            result = "Yes"
            break

    print(result)

resolve_mine()

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


def read():
    N, M = map(int, input().strip().split())
    A = []
    B = []
    for i in range(N):
        a = input().strip()
        A.append(a)
    for i in range(M):
        b = input().strip()
        B.append(b)
    return N, M, A, B


def solve(N, M, A, B):
    R = N - M
    C = len(A[0]) - len(B[0])
    if R < 0 or C < 0:
        return "No"
    L = len(B[0])
    for i in range(R+1):
        for j in range(C+1):
            is_match = True
            for k in range(M):
                if A[i+k][j:j+L] != B[k]:
                    is_match = False
                    break
            if is_match:
                return "Yes"
    return "No"


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

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

for i in range(N - M + 1):
    for j in range(N - M + 1):
        bb = []
        for k in range(M):
            bb.append(A[i + k][j:j+M])
        if bb == B:
            check = 1

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

Solution (Python):
import sys

N, M = map(int, sys.stdin.readline().strip().split())

A = []
for _ in range(N):
    A.append(list(sys.stdin.readline().strip()))

B = []
for _ in range(M):
    B.append(list(sys.stdin.readline().strip()))

for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for y in range(M):
            for x in range(M):
                if A[i+y][j+x] != B[y][x]:
                    flag = False
            if not flag:
                break
        if flag:
            print("Yes")
            sys.exit()
print("No")

Solution (Python):
import numpy

n, m = map(int, input().split())
a = numpy.zeros([n, n], dtype=int)
b = numpy.zeros([m, m], dtype=int)
for i in range(n):
    s = input()
    for j in range(n):
        if s[j] == '
            a[i, j] = 1
for i in range(m):
    s = input()
    for j in range(m):
        if s[j] == '
            b[i, j] = 1
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if numpy.all(a[i: i + m, j: j + m] == b):
            print("Yes")
            f = True
            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-M+1):
    for j in range(N-M+1):
        flag = True
        for y in range(M):
            for x in range(M):
                if A[j+y][i+x] != B[y][x]:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            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())

for i in range(N - M + 1):
    offset = 0
    while offset + M <= N:
        pos = A[i][offset:].find(B[0])        
        if -1 == pos:
            break
        offset += pos
        for j in range(1,M):
            if 0 != A[i+j][offset:].find(B[j]):
                offset += 1
                break
        else:
            print('Yes')
            exit()
else:
    print('No')

Solution (Python):
import numpy as np

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

found = False
for i in range(N-M+1):
    for j in range(N-M+1):
        P = A[i:i+M,j:j+M]
        if (P == B).all():
            print("Yes")
            found = True
            break
    if found: break
if not found:
    print("No")

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    A=[input() for _ in range(N)]
    B=[input() for _ in range(M)]
    for i in range(N-M+1):
        for j in range(N-M+1):
            for k in range(M):
                if A[i+k][j:j+M]!=B[k]:
                    break
            else:
                print('Yes')
                exit()
    print('No')

if __name__ == '__main__':
    main()

Solution (Python):
import sys

readline = sys.stdin.readline
N, M = map(int, readline().split())
A = [readline().rstrip() for _ in range(N)]
B = [readline().rstrip() for _ in range(M)]

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

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

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

print(ans)

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

A = np.array([[1 if i == "
B = np.array([[1 if i == "

if N == M:
    if np.all(A == B):
        print("Yes")
    else:
        print("No")
else:
    for i in range(N - M): 
        for j in range(N - M): 
            if np.all(A[i: M + i, j: M + j]== B):
                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_list = list()
for i in range(N-M+1):
    
    if B[0] in A[i]:
        ans = "T"
        y = A[i].find(B[0])
        
        for j in range(1,M):
    
            if A[i+j][y:y+M] == B[j]:
                ans += "T"
            else:
                ans += "F"
            
        ans_list.append(ans)

flag = False
for ans in ans_list:
    if "T" * M in ans:
        flag = True
    if flag:
        print("Yes")
        break
if not flag:
    print("No")

Solution (Python):
N,M=map(int,input().split())
a_l=[]
b_l=[]
for i in range(N):
    a_l.append(list(input()))
for i in range(M):
    b_l.extend(input())
count=0
for t in range (N-M+1):
    for k in range(N-M+1):
        tmp=[]
        for i in range(M):
            for j in range(M):
                tmp.append(a_l[t+i][k+j])
        if tmp == b_l:
            print('Yes')
            exit()
        else:
            continue
print('No')