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):
    A.append(input())
for i in range(m):
    B.append(input())
cnt=0
flag = False
for i in range(n-m+1):
    for j in range(n-m+1):
        ans = 'Yes'
        for k in range(m):
            for l in range(m):
                if A[i+k][j+l]!=B[k][l]:
                    ans = 'No'
        else:
            if ans == 'Yes':
                print(ans)
                exit()
print(ans)

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())
cnt=0
flag = False
for i in range(n-m+1):
    for j in range(n-m+1):
        ans = 'Yes'
        for k in range(m):
            for l in range(m):
                if A[i+k][j+l]!=B[k][l]:
                    ans = 'No'
        else:
            if ans == 'Yes':
                print(ans)
                exit()
print(ans)

Solution (Python):

def main():
    n, m = map(int, input().split())

    a_l = [input() for i in range(n)]
    b_l = [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):
                for l in range(m):
                    if a_l[i+k][j+l] != b_l[k][l]:
                        ans = 'No'
            else:
                if ans == 'Yes':
                    print(ans)
                    exit()
    print(ans)

  
        
if __name__ == '__main__':
    main()

Solution (Python):
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)
ans = "No"
for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j] == B[0][0]:
            count = 0
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] == B[k][l]:
                        count += 1
            if count == M*M:
                ans = "Yes"
                break
print(ans)

Solution (Python):



import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 2

.


.
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 1
....
....
....
....

        output = """No"""
        self.assertIO(input, output)


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

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

    print(ans)


if __name__ == "__main__":
    
    resolve()

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

for i in range(N-M+1):
  for j in range(N-M+1):
    f = 1
    for k in range(M):
      for l in range(M):
        if mp2[k][l] != mp1[i+k][j+l]:
          f = 0
          break
      if f == 0:
        break
    if f == 1:
      print('Yes')
      exit()
      
print('No')

Solution (Python):
def main():
    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):
            a_ = []
            for k in range(m):
                a_.append(a[i+k][j:j+m])
            if a_==b:
                print('Yes')
                return
    print('No')

if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

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

for i in range(N-M+1):
    for j in range(N-M+1):
        x=[s[j:M+j] for s in A[i:M+i]]
        if np.count_nonzero((x==B)==0) == 0:
            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 a:
    for j in b:
        if j not in i:
            print('No')
            exit()
print('Yes')

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

ans = False
for y in range(n-m+1):
    for x in range(n-m+1):
        sol = True
        for h in range(m):
            if a[y+h][x:x+m] != b[h]:
                sol = False
                break

        if sol:
            ans = True
            break
    if ans:
        break

print("Yes" if ans else "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())
flag = 0
for n_i in range(N - M + 1):
    for n_j in range(N - M + 1):
        for m_i in range(M):
            for m_j in range(M):
                if A[n_i + m_i][n_j + m_j] == B[m_i][m_j]:
                    continue
                break
            else:
                continue
            break
        else:
            flag = 1
            break
    else:
        continue
    break
if flag == 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)]
ans = "Yes"
for i in a:
  for j in b:
    if j not in i:
      ans = "No"
print(ans)

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

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

for i in range(N-M+1):
    if B[0] in A[i]:
        k = A[i].index(B[0])
        points = 1
        for j in range(1,M):
            if B[j] == A[i+j][k:k+M]:
                points += 1
        if points == M:
            print('Yes')
            exit()
print('No')

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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):
            correspond = True
            for p in range(m):
                for q in range(m):
                    if A[i + p][j + q] != B[p][q]:
                        correspond = False
                        break
            if correspond:
                print("Yes")
                return
    print("No")

if __name__ == "__main__":
    main()

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

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


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

print('No')

Solution (Python):




def solve(n,m,original,temp):
  def judge(sy,sx):
    for i in range(m):
      for j in range(m):
        if original[sy+i][sx+j] != temp[i][j]:
          return False
    return True
  

  sy = 0
  while sy + m - 1 < n:
    sx = 0
    while sx + m - 1 < n:
      if judge(sy,sx):
        return True
      sx += 1
    sy += 1

  return False

def main():
  N,M = map(int,input().split())
  a = [input() for _ in range(N)]
  b = [input() for _ in range(M)]
  print("Yes" if solve(N,M,a,b) else "No")
  return

if __name__ == '__main__':
  main()

Solution (Python):
import numpy as np
N,M = (int(T) for T in input().split())
A = np.zeros((N,N),dtype=bool)
B = np.zeros((M,M),dtype=bool)
for TN in range(0,N):
    A[TN,:] = [True if T=='.' else False for T in input()]
for TM in range(0,M):
    B[TM,:] = [True if T=='.' else False for T in input()]
MatchFlag = False
for TR in range(0,N-M+1):
    for TC in range(0,N-M+1):
        if np.sum(A[TR:TR+M,TC:TC+M]^B)==0:
            MatchFlag = True
print(['No','Yes'][MatchFlag])

Solution (Python):
import numpy

def main():
    n,m=map(int,input().split())
    a=numpy.array([list(input()) for _ in range(n)])
    b=numpy.array([list(input()) for _ in range(m)])
    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")
                return
    print("No")
    
if __name__ == "__main__":
    main()

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

for i in range(n):
    ln.append(input())
for i in range(m):
    lm.append(input())

lim = n - m + 1
for i in range(lim):
    for j in range(lim):
        l = 0
        for k in ln[i:i+m]:
            if k[j:j+m] != lm[l]:
                break
            l += 1
        else:
            print("Yes")
            break
    else:
        continue
    break

else:
    print("No")

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

Solution (Python):
n, m=map(int,input().split())
pic_a = [input() for _ in range(n)]
pic_b = [input() for _ in range(m)]
top = pic_b[0][0]
if m==1:
    for line_a in pic_a:
        for chr_a in line_a:
            if top==chr_a:
                print('Yes')
                exit()
    print('No')
    exit()
for i, line_a in enumerate(pic_a[:-m+1]):
    for j, chr_a in enumerate(line_a[:-m+1]):
        if top == chr_a:
            for k, line_b in enumerate(pic_b):
                if line_b != pic_a[i+k][j:j+m]:
                    break
            else:
                print('Yes')
                exit()
print('No')

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

if n == m:
    for i in range(n):
        if a[i] != b[i]:
            break
    else:
        print("Yes")
        exit()
    print("No")
    exit()

for i in range(n-m):
    start_h = i
    end_h = i+m
    for j in range(n-m):
        start_w = j
        end_w = j+m
        for k in range(m):
            if a[start_h+k][start_w:end_w] != b[k]:
                break
        else:
            print("Yes")
            exit()
print("No")

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    A = [SS() for _ in range(N)]
    B = [SS() for _ in range(M)]

    is_ok = False
    for i, j in itertools.product(range(N - M + 1), repeat=2):
        tmp = True
        for k in range(M):
            if B[k] != A[i+k][j:j+M]:
                tmp = False
                break
        if tmp:
            is_ok = True
            break

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

if __name__ == '__main__':
    resolve()

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

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

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

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

cnt=0
k=0
flag=0
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())

for j in range(n-m+1):
    k=0
    for i in range(n-m+1):
        if b[k]==a[i][j:j+m]:
            k+=1
            if k==m:
                print("Yes")
                flag+=1
                break
    else:
        continue
    break


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

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

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

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

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

print("No")

Solution (Python):
n,m = map(int,input().split())
a = ["" for _ in range(n)]
b = ["" for _ in range(m)]
for i in range(n):
  ai = str(input())
  a[i] = ai
for i in range(m):
  bi = str(input())
  b[i] = bi
for i in range(n-m+1):
  for j in range(n-m+1):
    flag = False
    for k in range(m):
      for l in range(m):
        if a[i+k][j+l] != b[k][l]:
          flag = True
          break
      if flag:
        break
    if not flag:
      print("Yes")
      exit()
print("No")

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

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

x=[input() for i in range(n)]
y=[input() for i in range(m)]

ans='No'

for i in range(n-m+1):
  for j in range(n-m+1):
    maze=[]
    for k in range(m):
      pin=''
      for l in range(m):
        pin+=x[i+k][j+l]
      
      maze.append(pin)

    if maze==y:
      ans='Yes'
      break


print(ans)

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

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

for i in range(0, n-m+1):
    for j in range(0, n-m+1):
        for k in range(m*m):
            if a[i+k//m][j+k%m] != b[k//m][k%m]:
                break
            elif k == m*m-1:
                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)]

def dfs(y, x):
    for Y in range(m):
        for X in range(m):
            if A[y+Y][x+X]!=B[Y][X]:
                return False
    return True

ans="No"
for y in range(n-m+1):
    for x in range(n-m+1):
        if A[y][x]==B[0][0]:
            if dfs(y,x):
                ans="Yes"
                break
    else:
        continue
    break

print(ans)

Solution (Python):
N, M = map(int, input().split())
if N < M:
  print('No')
else:
  A = [input() for _ in range(N)]
  B = ''
  cnt = 0
  for _ in range(M):
    B += input().rstrip()
  for i in range(N-M+1):
    if cnt==1:
      break
    for j in range(N-M+1):
      judge = ''
      for k in range(M):
        judge += A[i+k][j:j+M]
      if judge == B:
        cnt += 1
        break
  if cnt == 1:
    print('Yes')
  else:
    print('No')

Solution (Python):
import sys
N,M=map(int,input().split())
A=[]
for i in range(N):
  a=input()
  A.append(a)
B=[]
for j in range(M):
  b=input()
  B.append(b)
for k in range(N-M+1):
  for l in range(N-M+1):
    z=0
    for m in range(M):
      try:
        if B[m]==A[k+m][l:l+M]:
          z+=1
      except:
        sys.stderr.write(f"{k,l,m}")
        pass
    if z==M:
      print("Yes")
      sys.exit()
print("No")

Solution (Python):
N,M = map(int,input().split())
Als = []
Bls = []
ans = 'No'
if Bls == Als:
    ans = 'Yes'
for i in range(N):
    Als.append(input())
for i in range(M):
    Bls.append(input())
for i in range(N-M):
    for j in range(0,N-M):
        for k in range(M):
            if Bls[k] == Als[i+k][j:M+j]:
                ans = 'Yes'
            else:
                ans = 'No'
                break
        if ans == 'Yes':
            break
    if ans == 'Yes':
        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)]
r=n-m+1
print('Yes' if any([all([a[x//r+y//m][x%r+y%m]==b[y//m][y%m] for y in range(m**2)]) for x in range(r**2)]) else 'No')

Solution (Python):
n,m=map(int,input().split())
a=[list(input()) for _ in range(n)]
b=[list(input()) for _ in range(m)]
r=n-m+1
for x in range(r**2):
  for y in range(m**2):
    if a[x//r+y//m][x%r+y%m]!=b[y//m][y%m]:
      break
  else:
    print('Yes')
    break
else:
  print('No')

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

eq = False
find = False
for i in range(n-m+1):
  for j in range(n-m+1):
    for p in range(m):
      for q in range(m):
        if a[p+i][q+j] == b[p][q]:
          eq = True
        else:
          eq = False
          break
      if not eq:
        break
    if eq:
      find = True
      break
  if find:
    break
if find:
  print('Yes')
else:
  print('No')

Solution (Python):
n, m = map(int, input().split())
a = ["" for _ in range(n)]
b = ["" for _ in range(m)]
for i in range(n):
    a[i] = str(input())
for i in range(m):
    b[i] = str(input())
def check(ini_x, ini_y):
    global n, m, a, b
    for x in range(m):
        for y in range(m):
            if a[ini_x + x][ini_y + y] != b[x][y]:
                return False
    return True
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):
N,M=list(map(int, input().split()))
A=[list(input()) for _ in range(N)]
B=[list(input()) for _ in range(M)]
K=N-M+1

for i in range(K):
  for j in range(K):
    
    if all(all(A[k+i][l+j] == B[k][l] for l in range(M)) for k in range(M)):
      print('Yes')
      exit()
else:
  print('No')

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

for i in range(n-m+1) :
    for j in range(n-m+1) :
      match = True
      for k in range(m) :
        for l in range(m) :
          if an[i+k][j+l] != bm[k][l] :
            match = False
            break
          else :
            continue
      if match :
        print("Yes")
        exit()
                    
print("No")

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

a_list = []
b_list = []
ans = "No"

for i in range(n):
    a_list.append(input())

for i in range(m):
    b_list.append(input())

for i in range(n-m+1):
    for j in range(n-m+1):
        match = True
        for k in range(m):
            for l in range(m):
                if a_list[i+k][l+j] != b_list[k][l]:
                    match = False
        if match:
            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)]
for i in range(N-M+1) :
    for j in range(N-M+1) :
        a = True
        for k in range(M) :
            for l in range(M) :
                if A[i+k][j+l] != B[k][l] :
                    a = False
                    break
                else :
                    continue
                break
        if a :
            print('Yes')
            exit()
                    
print('No')

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


isOK = False









for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j:j+m] == b[0]:
            cnt = 1
            for k in range(1,m):
                if a[i+k][j:j+m] == b[k]:
                    cnt += 1
            if cnt == m:
                isOK = True
                break
if isOK:
    print('Yes')
else:
    print('No')

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

f = False
for i in range(N*N):
  if f == True:
    break
  if N*N-i<M*M:
    break
  if M>1 and i//N==N-1:
    break
  count=0
  flag = True
  
  if c[0] == a[i]:
    if N-((i)%N)<M:
      continue
    num = i
    for j in range(M):
      for k in range(M):
        
        if c[count] == a[num]:
          
          num+=1
          count+=1
        elif c[count]!=a[num]:
          flag =False
          break
      num+=N-M
      if flag == False:
        
        break  
      if j == M-1:
        f = True
            
  else:
    continue
if f == False:
  print('No')
else:
  print('Yes')

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

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

img_a = []
img_b = []

for i in range(n):
    img_a.append(list(input().strip()))

for i in range(m):
    img_b.append(list(input().strip()))


if img_a == img_b:
    print("Yes")
    sys.exit()

for i in range(0, n - m + 1):
    for j in range(0, n - m + 1):
        grid = [line[j:j + m] for line in img_a[i:i + m]]
        if grid == img_b:
            print("Yes")
            sys.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 c(a, m, x, y):
  tmp = []
  for i in range(m):
    tmp.append(a[y+i][x:x+m])
  return tmp

for x in range(n - m + 1):
  for y in range(n - m + 1):
    if c(a, m, x, y) == b:
      print("Yes")
      exit(0)
print("No")

Solution (Python):
def resolve():
    N, M = map(int, input().split())
    A = []
    B = []
    ans = 0
    for _ in range(N):
        a = input()
        A.append(a)
    for __ in range(M):
        b = input()
        B.append(b)
    for i in range(N-M+1):
        for j in range(N-M+1):
            flag = 0
            for p in range(M):
                for q in range(M):
                    if A[i+p][j+q] != B[p][q]:
                        flag = 1
            if flag == 0:
                ans = 1
    print("Yes" if ans == 1 else "No")
resolve()

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

print(ans)

Solution (Python):
import numpy as np

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

A=[list(map(int,list(input().replace('.','0').replace('
B=[list(map(int,list(input().replace('.','0').replace('

A,B=map(np.array,(A,B))

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

b_str = ''.join(B_list)
def judge_same(str1, str2):
    return str1 == str2
judge = False
finish = False
for i in range(N - M + 1):
    for j in range(N - M + 1):
        a_str = ''.join([A_list[i + x][j:(j+M)] for x in range(M)])
        judge = judge_same(a_str, b_str)
        if judge:
            finish = True
            break
    if finish:
        break
if judge:
    print('Yes')
else:
    print('No')

Solution (Python):
def hasB(A, B, M, x, y):
  has = True
  for i in range(M):
    for j in range(M):
      if A[y + i][x + j] != B[i][j]:
        has = False
  return has


N, M = list(map(lambda x: int(x), input().split(" ")))
A = []
B = []
for i in range(N):
  A.append(list(input()))
for j in range(M):
  B.append(list(input()))

has = False
for i in range(N - M + 1):
  for j in range(N - M + 1):
    if A[i][j] == B[0][0]:
      has = hasB(A, B, M, j, i)
      if has:
        break
  else:
    continue
  
  break

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

Solution (Python):
n,m = map(int, input().split())
a = [str(input()) for i in range(n)]
b = [str(input()) for i in range(m)]
for i in range(0,n-m+1):
    for j in range(0,n-m+1):
        ans = 1
        for k in range(0,m):
            for l in range(0,m):
                if a[i+k][j+l] != b[k][l]:
                    ans = 0
                    break
        if ans == 1:
            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 s in range(N-M+1):
    for t in range(N-M+1):
        match = True
        for i in range(M):
            for j in range(M):
                if A[i+s][j+t] != B[i][j]:
                    match = False
                    break
            else:
                continue
            break
        if match:
            print('Yes')
            exit()
print('No')

Solution (Python):
def solve():
    def check(i, j, m):
        for h in range(m):
            for w in range(m):
                if A[h+i][w+j] != B[h][w]:
                    return False
        return True
    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 check(i, j, M):
                print("Yes")
                return
    print("No")
    return

solve()

Solution (Python):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
a = [list(input())[: -1] for _ in range(N)]
b = [list(input())[: -1] for _ in range(M)]
for i in range(N - M + 1):
  for j in range(N - M + 1):
    for y in range(M):
      for x in range(M):
        if a[i + y][j + x] != b[y][x]: break
      else: continue
      break
    else:
      print("Yes")
      exit(0)
print("No")

Solution (Python):








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




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

temp = n - m + 1


for i in range(temp):
    for j in range(temp):
        
        for k in range(m):
            for l in range(m):
                if equal(a,b,i,j,m):
                    print("Yes")
                    exit()
print("No")

Solution (Python):
import numpy as np
n, m = map(int, input().split())
A = [list(input()) for _ in range(n)]
B = [list(input()) for _ in range(m)]

A, B = np.array(A), np.array(B)

for i in range(n-m+1):
    for j in range(n-m+1):
        tmp = A[i:i+m, j:j+m]
        
        
        if (tmp == B).all():
            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)]
b1=b[0]
res="No"
for i in range(n-m+1):
    if b1 in a[i]:
        x=a[i].index(b1)
        match=1
        for j in range(1,m):
            if a[i+j][x:x+m]!=b[j]:
                match=0
        if match:
            res="Yes"
print(res)

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

Solution (Python):
n, m = [int(s) for s in input().split()]
a_list = [input() for _ in range(n)]
b_list = [input() for _ in range(m)]
stop = n - m + 1
for i in range(stop):
    for j in range(stop):
        break_flag = False
        for x in range(m):
            for y in range(m):
                if a_list[i + x][j + y] != b_list[x][y]:
                    break_flag = True
                    break
            if break_flag:
                break
        else:
            print("Yes")
            exit()
print("No")