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

ans = False
for i in range(n-m+1):
    for j in range(n-m+1):
        bad = False 
        for k in range(m):
            for l in range(m):
                if grida[k+i][l+j] != gridb[k][l]:
                    bad = True
        if not bad:
            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)]

if N == M:
    if A == B:
        print("Yes")
    else:
        print("No")
    exit()

for a_i in range(N-M):
    if B[0] in A[a_i]:
        
        start = []
        for a_j in range(N-M+1):
            if B[0] == A[a_i][a_j:M+a_j]:
                start.append(a_j)
        for s in start:
            f = True
            for b_i in range(M):
                
                if B[b_i] != A[a_i+b_i][s:s+M]:
                    f = False
            if f == True:
                print("Yes")
                exit()
print("No")

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

def search(h,w):
    for i in range(m):
        if not b[i]==a[h+i][w:w+m]:
            return False
    return True

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

def chk(upper, left):
    for i in range(m):
        for j in range(m):
            if a[i+upper][j+left] != b[i][j]:
                return False
    return True

f = False
for upper in range(n-m+1):
    for left in range(n-m+1):
        if chk(upper, left):
            print('Yes')
            f = True
            break
    if f:
        break
if not f:
    print('No')

Solution (Python):
import numpy as np
N, M = 3, 2

ARR = [
    list("
    list(".
    list("
]

ARR2 = [
    "
    ".
]































N,M = map(int,input().split())
ARR = []

for i in range(N):
    ARR.append(list(input()))

ARR2 = []

for j in range(M):
    ARR2.append(input())


def calculate(n, m, arr1, arr2):
    arr1 = np.array(arr1)
    isOK = False
    for j in range(0, n - m + 1):
        for i in range(0, len(arr1[0]) - len(arr2[0]) + 1):
            
            c1 = arr1[j:j + m,i:i + len(arr2[0])]
            s1 = np.ravel(c1)
            s1 = "".join(s1)
            s2 = "".join(arr2)
            if s1 == s2:
                isOK = True
                break

        if isOK == True:
            break

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


calculate(N, M, ARR, ARR2)

Solution (Python):
def grinp(h):
  ret=[]
  for i in range(h):
    ret.append(list(input()))
  return ret
n,m=map(int,input().split())
ngr=grinp(n)
mgr=grinp(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 ngr[i+k][j+l]!=mgr[k][l]:
          flag=False
          break
      if not flag:
        break
    if flag:
      print("Yes")
      break
  if flag:
    break
else:
  print("No")

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

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

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

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


for i in range(N-M+1):
    for j in range(N-M+1):
        flg = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] == B[k][l]:
                    pass
                else:
                    flg=False
                    break
            if flg==False:
                break

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

Solution (Python):
import sys,math,collections,itertools
input = sys.stdin.readline

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

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

for h in range(N-M+1):
    for w in range(N-M+1):
        cutA = [ A[h+i][w:w+M] for i in range(M)]
        if cutA == B:
            print('Yes')
            exit()
        else:
            continue
        
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 di,dj in [(pi,pj) for pi in range(n-m+1) for pj in range(n-m+1)]:
    for i,j in [(pi,pj) for pi in range(m) for pj in range(m)]:
        if a[di+i][dj+j] != b[i][j]:
            break
    else:
        ans = 'Yes'
        break
print(ans)

Solution (Python):
n,m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
ans = False
for pattern_h in range(n-m+1):
  for pattern_w in range(n-m+1):
    p = []
    for h in range(m):
      p.append(a[pattern_h+h][pattern_w:pattern_w+m])
    if p==b:
      ans = True
      break
  if ans: break
print('Yes' if ans else 'No')

Solution (Python):

import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n, m = LI()
a = SR(n)
b = SR(m)
ans = 'No'
for h in range(n - m + 1):
    for w in range(n - m + 1):
        is_ok = True
        for i in range(m):
            for j in range(m):
                if a[h + i][w + j] != b[i][j]:
                    is_ok = False
                    break
        if is_ok:
            ans = 'Yes'
            break
print(ans)

Solution (Python):
s = input().split()

n = int(s[0])
m = int(s[1])

N = [[0 for j in range(n)] for i in range(n)]

M = [[0 for j in range(m)] for i in range(m)]

for num in range(n):
    p = input()
    words = list(p)
    for number in range(n):
        N[num][number] = words[number]

for num in range(m):
    p = input()
    words = list(p)
    for number in range(m):
        M[num][number] = words[number]



exist = False

for num in range(n):
    for number in range(n):
        if num + m - 1 >= n or number + m - 1 >= n:
            continue

        check = True
        for i in range(m):
            for j in range(m):
                if N[num + i][number + j] != M[i][j]:
                    check = False
        
        if check:
            exist = True

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

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    A = [iss() for _ in range(N)]
    B = [iss() for _ in range(M)]

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    A = [iss() for _ in range(N)]
    B = [iss() for _ in range(M)]

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


if __name__ == '__main__':
    main()

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

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

for i in range(n):
    a.append(input())
for j in range(m):
    b.append(input())




"""ボツ案
a_pix = []
b_pix = []
a_temp = []
b_temp = []

judge = ''

for i in a:
    for i_pix in i:
        a_temp.append(i_pix)
    a_pix.append(a_temp)
    a_temp = []

for j in b:
    for j_pix in j:
        b_temp.append(j_pix)
    b_pix.append(b_temp)
    b_temp = []



"""

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


        judge = 'Yes'
        for k in range(m):
            for l in range(m):
                
                if a[i+k][j+l] != b[k][l]:
                    judge = 'No'

        if judge == 'Yes':
            print('Yes')
            exit()

print('No')

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

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

print("No")

Solution (Python):
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
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):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    break
            else:
                continue
            break
        else:
            ans = "Yes"
            break
    else:
        continue
    break

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, M = mi()
    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):
            bl = True
            for i in range(M):
                for j in range(M):
                    if A[x+i][y+j] != B[i][j]:
                        bl = False
            if bl:
                print('Yes')
                return
    print('No')

if __name__ == '__main__':
    main()

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

for i in range (n-m+1):
  for j in range(n-m+1):
    g=1
    for k in range(m):
      
      if a[i+k][j:j+m]!=b[k]:
        g*=0
        break
    if g==1:
      print("Yes")
      import sys
      sys.exit()
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):
        match = 1
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    match = 0
        if match:
            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 = False

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

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

Solution (Python):
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in read() if s != ord('\n')]


def main():
    N, M = in_nn()
    t = in_map()
    A = np.array(t[:N * N]).reshape(N, N)
    B = np.array(t[N * N:]).reshape(M, M)

    ans = 'No'
    for y in range(N - M + 1):
        for x in range(N - M + 1):
            if np.all(A[y:y + M, x:x + M] == B):
                ans = 'Yes'

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys 

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


c = N - M + 1

for ic in range(c):
    for jc in range(c):
        cnt = 0
        for i in range(M):
            for j in range(M):
                if A[ic + i][jc + j] == B[i][j]:
                    cnt += 1

        if cnt == M * M:
            print("Yes")
            sys.exit()
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 x in range(0, n - m + 1):
    for y in range(0, n - m + 1):
        check = True
        for i in range(m):
            for j in range(m):
                if a[i+x][j+y] != b[i][j]:
                    check = False
                    break
            if check == False:
                break
        if check == True:
            ans = 'Yes'
            break
print(ans)

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):
        if (A[i:i+m, j:j+m] == B).all():
            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)]
isIn = False
for i in range(N - M + 1):
    for j in range(N - M + 1):
        isOK = True
        for now in range(M):
            if A[i+now][j:j+M] != B[now]:
                isOK = False
                break
        if isOK:
            isIn = True
            break
    if isIn:
        break
if isIn:
    print("Yes")
else:
    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)]

for i in range(n-m+1):
    for j in range(n-m+1):
        t = 1
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] != b[k][l]:
                    t = 0
        if t == 1:
            print('Yes')
            exit(0)

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

Solution (Python):
n,m = map(int,input().split())
a = [0]*n
for i in range(n):
    a[i] = list(input())
b = [0]*n
for i in range(m):
    b[i] = list(input())
ans = 0
for i in range(0,n-m+1):
    if ans == 1:
        break
    for j in range(0,n-m+1):
        sw = 1
        for x in range(m):
            for y in range(m):
                if a[i+x][j+y] == b[x][y]:
                    pass
                else:
                    sw = 0
        if sw == 1:
            ans = 1
            break
print(["No","Yes"][ans])

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

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

for i in range(n - m + 1):
    for j in range(n - m + 1):
        for k, row in enumerate(blst):
            if alst[i + k][j:j + m] == blst[k]:
                continue
            break
        else:
            print("Yes")
            exit()
print("No")

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

def main():
    N, M = map(int, input().split())
    A = [list(input().rstrip()) for _ in range(N)]
    B = [list(input().rstrip()) for _ in range(M)]
    mv = N - M + 1
    for i in range(mv):
        for j in range(mv):
            sub_A = [r[j:j+M] for r in A[i:i+M]]
            if sub_A == B:
                print("Yes")
                exit()
    print("No")


if __name__ == '__main__':
    main()

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

w_dif = len(A[0])-len(B[0])
w_w = len(B[0])
ans = 'No'
for h in range(n-m+1):
    for w in range(w_dif+1):
        window = [wh[w:w+w_w] for wh in A[h:h+m]]
        if window==B:
            ans = 'Yes'
            break
print(ans)

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

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

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

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

Solution (Python):
import numpy as np

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

aa = np.zeros((n,n), dtype=int)
for i in range(n):
    for j in range(n):
        if a[i][0][j] == '
            aa[i][j] = 1

bb = np.zeros((m,m), dtype=int)
for i in range(m):
    for j in range(m):
        if b[i][0][j] == '
            bb[i][j] = 1

flg = False
for i in range(n-m+1):
    for j in range(n-m+1):
        aaa = aa[i:i+m,j:j+m]
        if np.all(aaa == bb):
            flg = True

print('Yes') if flg 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 = True
        count = 0
        for k in range(M):
            if (A[i + k][j: j + M] == B[k]):
                
                count += 1
                continue
            else:
                check = False
                break

        if (check and count == M):
            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 range(M):
            if A[i+k][j:j+M]==B[k]:
                cnt+=1
        if cnt==M:
            print("Yes")
            exit()
print("No")

Solution (Python):
N,M,*f = open(0).read().split()
N = int(N)
M = int(M)
A = f[:N]
B = f[N:]
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 A[i+k][j:j+M] != B[k]:
                    break
            else:
                print('Yes')
                break
    else:
        continue
    break
else:
    print('No')

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

for i in range(N - M + 1):
  for j in range(N - M + 1):
    if A[i][j:j + M] == B[0]:
      for k in range(1, 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())
A = [list(map(str,list(input()))) for i in range(n)] 
B = [list(map(str,list(input()))) for i in range(m)] 
def move(h,w):
    cnt = 0
    for i in range(m):
        for j in range(m):
            if B[i][j] == A[i+h][j+w]:
                cnt += 1
    return cnt
flg = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        if move(i,j)==m*m:
            flg = 1
            break
if flg == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
N,M = map(int,input().rstrip().split(" "))
A = []
B = []
ans = False
for i in range(N):
    A.append(list(input()))
for i in range(M):
    B.append(list(input()))
for i in range(N - M + 1):
    for i2 in range(N - M + 1):
        for i3 in range(M):
            if A[i3 + i][i2:i2 + M] != B[i3]:
                break
            if i3 == M -1:
                ans = True
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
N,M = map(int,input().split())
A = np.array([list(input()) for n in range(N)])
B = np.array([list(input()) for m in range(M)])
a = "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():
      a = "Yes"

print(a)

Solution (Python):
import numpy as np

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

A=np.array(A)
B=np.array(B)
ans="No"
for i in range(N):
    for j in range(N):
        if i+M<=N and j+M<=N:
            if (A[i:i+M, j:j+M]==B).all():
                ans="Yes"

print(ans)

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

for i in range(N-M+1):
    for j in range(N-M+1):
        ok = True
        for y in range(M):
            for x in range(M):
                if A[i+y][j+x] != B[y][x]:
                    ok = False
        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)]

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

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

def main(n,m,a,b):
    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:
                return 'Yes'
    return 'No'

if __name__=='__main__':
    n,m,a,b=readinput()
    ans=main(n,m,a,b)
    print(ans)

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

for _ in range(N):
    a.append(input())
for _ in range(M):
    b.append(input())
flg = True
for i in range(N):
    for j in range(N-M+1):
        
        if a[i][j:j+M] == b[0]:
            if M == 1:
                print('Yes')
                exit()
            else:
                for k in range(1,M):
                    if a[k][j:j+M] != b[k]:
                        flg = False
                        break
                if flg:
                    print('Yes')
                    exit()
                else:
                    flg = True
print('No')

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

r = n - m + 1
for i_r in range(r):
    for j_r in range(r):
        ok = True
        for i in range(m):
            for j in range(m):
                if a[i_r + i][j_r + j] != b[i][j]:
                    ok = False
        if ok:
            print('Yes')
            exit(0)

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 ly in range(N):
    for lx in range(N):
        if N - M + 1 <= lx:
            continue
        if N - M + 1 <= ly:
            continue
        flag = True
        for y in range(M):
            for x in range(M):
                if B[y][x] != A[ly+y][lx+x]:
                    flag = False
        if flag:
            ans = True

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

Solution (Python):
def resolve():
    '''
    code here
    '''

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

    is_found = False
    for i in range(N-M+1):
        temp_line = A[i:i+M]
        for j in range(N-M+1):
            temp_grid = [line[j:j+M] for line in temp_line]
            
            if B == temp_grid:
                is_found = True
                break
        if is_found:
            break

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

if __name__ == "__main__":
    resolve()

Solution (Python):


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

A = []
B = []

for i in range(N):
    A.append(list(map(str, input())))

for i in range(M):
    B.append(list(map(str, input())))

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

print('No')

Solution (Python):
import sys
N, M = map(int, input().split())
A = [list(map(str, input())) for _ in range(N)]
B = [list(map(str, 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):
            for l in range(M):
                if A[i + k][j + l] != B[k][l]:
                    OK = False
                    break
            if not OK:
                break
        if OK:
            print('Yes')
            sys.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)]
flag = False

for x1 in range(N - M + 1):
    for x2 in range(N - M + 1):
        check = True
        for y in range(M):
            for z in range(M):
                if A[z + x1][y + x2] != B[z][y]:
                    check = False

                
                
        if check:
            flag = True
            break

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