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

for i in range(min(N - M + 2, N)):
	for j in range(min(N - M + 2, N)):
		
		if A[i][j: j + M] == B[0]:
			tmp = True
			for k in range(1, M):
				if A[i + k][j: j + M] == B[k]:
					pass
				else:
					tmp = False
					break
			if tmp:
				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='No'
 
for i in range(n-m+1):
    for j in range(n-m+1):
        C=[A[i+k][j:j+m] for k in range(m)]
        if B==C:
            ans='Yes'
        
print(ans)

Solution (Python):
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
r=any([r[j:j+m] for r in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1))
print('Yes' if r else 'No')

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

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

cnt = 0
flg = '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]:
                    cnt += 1
        if cnt == m ** 2:
            flg = 'Yes'
        else:
            cnt = 0
print(flg)

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

def check(A,B,i,j):
    for yoko in range(M):
        for tate in range(M):
            if A[tate+i][yoko+j] != B[tate][yoko]:
                return False
    return True
    
for i in range(frd+1):
    for j in range(frd+1):
        if check(A,B,i,j):
            print("Yes")
            exit()
print("No")

Solution (Python):
import sys
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 = np.array(a)
b = np.array(b)

for i in range(0, n-m+1):
    for j in range(0, n-m+1):
        if (a[i:i+m,j:j+m] == b).all():
            print('Yes')
            sys.exit()

print('No')

Solution (Python):
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for j in range(m)]
out = "No"
for i in range(n-m+1):
    for j in range(n-m+1):
        cnt = 0
        for k in range(m):
            for l in range(m):
                if b[k][l] == a[i+k][j+l]:
                    cnt += 1
        if cnt == m**2:
            out = "Yes"
            break
print(out)

Solution (Python):
n,m = map(int,input().split())
a = [input() for i in range(n)]
b = [input() for j in range(m)]
ans = "No"
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[i+k][j+l]:
                    count += 1
        if count == m*m:
            ans = "Yes"
            break

print(ans)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys


mod = 10**9+7
sys.setrecursionlimit(mod) 

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

ans = False
for y in range(N-M+1):
    for x in range(N-M+1):
        for i in range(M):
            for j in range(M):
                if A[x+i][y+j] == B[i][j]:
                    pass
                else:
                    break
            else:
                continue
            break
        else:
            ans = True

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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,m = f()
    a = [""] * n
    b = [""] * m
    for i in range(n):
        a[i] = input()
    
    for i in range(m):
        b[i] = input()
    
    if m>n:
        print("No")
    else:
        for i in range(0, n - m+1):
            for j in range(0, n - m+1):
                ok = True
                for k in range(m):
                    if a[i+k][j:j+ m] != b[k]:
                        ok = False
                if ok:
                    print("Yes")
                    return
        
        print("No")


solve()

Solution (Python):

"""
B - Template Matching
https://atcoder.jp/contests/abc054/tasks/abc054_b

"""
import sys


def solve(N, M, A, B):
    for y in range(0, N-M+1):
        for x in range(0, N-M+1):
            for m in range(M):
                t = A[y+m][x:x+M]
                if t != B[m]:
                    break
            else:
                return 'Yes'
    return 'No'


def main(args):
    N, M = map(int, input().split())
    A = [input() for _ in range(N)]
    B = [input() for _ in range(M)]
    ans = solve(N, M, A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

ans = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        inc = True
        for ii in range(m):
            for jj in range(m):
                if a[i+ii][j+jj] != b[ii][jj]:
                    inc = False

        if inc:
            ans = True

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

Solution (Python):
n,m=map(int,input().split())
a=[input() for i in range(n)]
b=[input() for i in range(m)]
f=0
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:
            f=1
            break
    if f==1:break
print("Yes" if f else "No")

Solution (Python):
N , M = map(int, input().split())
As =[input() for _ in range(N)]
Bs =[input() for _ in range(M)]
m = N-M
for i in range(m+1):
    for j in range(m+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if As[k+i][l+j] != Bs[k][l]:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            break
    if flag:
        break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
from itertools import product

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

for i, j in product(range(N-M+1), range(N-M+1)):
    A_partial = [a[j:j+M] for a in A[i:i+M]]
    if A_partial == B:
        print('Yes')
        break
else:
    print('No')

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

a_grid = [list(input()) for _ in range(n)]
b_grid = [list(input()) for _ in range(m)]

for r in range(n-m+1):
  for c in range(n-m+1):
    for x in range(m):
      if a_grid[r+x][c:c+m] != b_grid[x][:]:
        break
    else:
      print("Yes")
      sys.exit()
print("No")

Solution (Python):
ans='No'
X=''
Y=''
n=0
a,b=map(int,input().split())
x=[0]*(a*a)
y=[0]*(b*b)
for i in range(a):
    for s in input().split():
        X+=s
for i in range(b):
    for s in input().split():
        Y+=s

for h in range(a-b+1):
    for w in range(a-b+1):
        p_X=''
        for t in range(b):
            p_X+=X[(h+t)*a+w:(h+t)*a+w+b]
        if p_X==Y:
            ans='Yes'
print(ans)

Solution (Python):
n,m=map(int,input().split())
a=[input() for q in range(n)]
b=[input() for w in range(m)]
Flag=False
for i in range (n-m+1):
    for j in range (n-m+1):
        Flag=False
        for I in range(m):
            for J in range(m):
                if a[i+I][j+J]==b[I][J]:
                    continue
                else:
                    Flag=True
                    break
        if Flag:
            continue
        else:
            print("Yes")
            exit()
print("No")

Solution (Python):



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

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

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

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

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

frag = False
for i in range(N - K + 1):
  for j in range(N - K + 1):
    f = True
    for k in range(K):
      for l in range(K):
        if A[i + k][j + l] != B[k][l]:
          f = False
    if f:
      frag = True
print("YNeos"[not frag::2])

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

print(ans)

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

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

Solution (Python):
[n,m] = [int(i) for i in input().split()]
a = []
b = []
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())
cnt = 0
flag = "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]:
                    cnt += 1

        if cnt == m ** 2:
            flag = "Yes"
        else:
            cnt = 0
print(flag)

Solution (Python):
n,m = map(int,input().split())
A = [input() for i in range(n)]
B = [input() for i in range(m)]
if n == m:
    if all(A[i]==B[i] for i in range(n)):
        print("Yes")
        exit()
    else:
        print("No")
        exit()
for i in range(n-m):
    for j in range(n-m):
        bool = True
        for l in range(m):
            if A[i+l][j:j+m] == B[l]:
                continue
            else:
                bool = False
        if bool:
            print("Yes")
            exit()
print("No")

Solution (Python):
N, M = map(int, input().split())
n = []
m = []
for i in range(N):
  s = str(input())
  row = []
  for j in range(N):
    if s[j] == "
      row.append(1)
    else:
      row.append(0)
  n.append(row)
for i in range(M):
  s = str(input())
  row = []
  for j in range(M):
    if s[j] == "
      row.append(1)
    else:
      row.append(0)
  m.append(row)
 
def search(a,b):
  mr = mc = 0
  for r in range(a, a+M):
    for c in range(b, b+M):
      if n[r][c] != m[mr][mc]:
        return False
      mc += 1
    mr += 1
    mc = 0
  return True

ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    if search(i,j):
      ans = 1
      break
  if ans:
    break
if ans:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys
sys.setrecursionlimit(1000000)

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

flag = False
for i in range(N-M):
    for j in range(N-M):
        flagx = True
        for x in range(M):
            if(A[i+x][j:j+M]!=B[x]):
                flagx = False
        if(flagx):
            flag = flag|flagx
            break

if(flag or (N==1 and M==1)):
    print('Yes')
else:
    print('No')

Solution (Python):
N, M = map(int, input().split())
data = []
for i in range(N):
  data.append(input())
input_data=[]
for i in range(M):
  input_data.append(input())
flag_1 = False
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 data[i+k][j+l] != input_data[k][l]:
          flag = False
    if flag:
      flag_1 = True

if flag_1:
  print("Yes")
else:
  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())
t=0
while t==0:
    for i in range(N-M+1):
        for j in range(len(A[0])-len(B[0])+1):
            m=0
            for h in range(M):
                for k in range(len(B[0])):
                    if B[h][k]==A[h+i][k+j]:
                        m+=1
            if m==M*len(B[0]):
                print('Yes')
                t=1
                break
        if t==1:
            break
    else:
        print('No')
        break

Solution (Python):


def solve(N, M, A, B):
    include = False
    for h in range(N-M+1):
        for w in range(N-M+1):
            match = True
            for i in range(M):
                for j in range(M):
                    if(A[h+i][w+j] != B[i][j]):
                        match = False
            if(match):
                include = True

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

if __name__ == '__main__':
    N, M = map(int, input().split())
    A, B = [], []
    for i in range(N):
        A.append(input())
    for j in range(M):
        B.append(input())

    solve(N, M, A, B)

Solution (Python):
N,M = map(int,input().split())
A = [input() for _ in [0]*N]
B = [input() for _ in [0]*M]
endFlg = False
for i in range(N-M+1):
    for j in range(N-M+1):
        breakFlg = False
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    breakFlg = True
                    break
            if breakFlg:break
        else:endFlg=True
        if endFlg: break
    if endFlg: break
if endFlg: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):
        flag1=0
        for k in range(M):
            if B[k] != A[i+k][j:j+M]:
                flag1=1
                break
        if flag1==0:
            break
    if flag1==0:
        break
if flag1 == 0:
    print("Yes")
else:
    print("No")

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

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

n = N - M + 1

for i in range(n*n):
    j = i // n
    i %= n
    flag = True
    for k in range(M*M):
        l = k // M
        k %= M
        if A[j+l][i+k] != B[l][k]:
            flag = False
            break
    if flag:
        print("Yes")
        exit()

print("No")

Solution (Python):
n, m = [int(i) for i in input().split()]
a = []
b = []
flag_yes = 0
for i in range(n):
  a.append(input())
for i in range(m):
  b.append(input())
for ri in range(n-m+1):
  for ci in range(n-m+1):
    c = []
    for mi in range(m):
      c.append(a[ri+mi][ci:ci+m])
    if c == b:
      flag_yes = 1
if flag_yes == 1:
  print("Yes")
else:
  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))
c=0
if a==b:
    c=1
for i in range(n-m):
    for j in range(n-m):
        if all(a[i+k][j:j+m]==b[k]  for k in range(m)):
            c=1
            break
print('Yes' if c==1 else 'No')

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

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

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

includes = False
for r in range(N - M + 1):
    for c in range(N - M + 1):
        for i in range(M):
            for j in range(M):
                if A[r + i][c + j] != B[i][j]:
                    break
            else:
                continue
            break
        else:
            includes = True

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

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

includes = False
for r in range(N - M + 1):
    for c in range(N - M + 1):
        matches = True
        for i in range(M):
            for j in range(M):
                if A[r + i][c + j] != B[i][j]:
                    matches = False
        if matches:
            includes = True

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

Solution (Python):
a, b = (int(i) for i in input().split())  

x = [input() for i in range(a)]
y = [input() for i in range(b)]

h = a - b + 1
w = len(x) - len(y) + 1
res = "No"

for i in range(h):
  for ii in range(w):
    if all([y[z] == x[i+z][ii:ii+len(y)] for z in range(b)]):
      res = "Yes"
      break

print(res)

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

Solution (Python):
n,m=map(int,input().split())
ans='No'
a=[]
b=[]
for i in range(n):
    a1=list(input())
    a.append(a1)
for j in range(m):
    b1=list(input())
    b.append(b1)
for i in range(n-m+1):
    for j in range(n-m+1):
        if b==[l[i:i+m] for l in a[j:j+m]]:
            ans='Yes'
            break
print(ans)

Solution (Python):
N,M=map(int,input().split())
A=[]
for i in range(N):
    A.append(list(input()))
B=[]
for i in range(M):
    B.append(list(input()))
f = False
for i in range(N-M+1):
    for j in range(N-M+1):
        g = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l]!=B[k][l]:
                    g = False
        if g:
            f = True
print("Yes" if f else "No")

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

for i in range(n-m+2):
	c = a[i:i+m]
	for j in range(n-m+2):
		d = [e[j:j+m] for e in c]
		if b == d:
			ans = 'Yes'
print(ans)

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

l = 0
while l <= len(A[0]) - len(B[0]):
	for i in range(N - M + 1):
		s = A[i][l:]
		if not B[0] in s:
			continue
		if 0 == s.index(B[0]):
			for m in range(1, M):
				if not B[m] in A[i + m][l:]:
					break
				if 0 != A[i + m][l:].index(B[m]):
					break
			else:
				print("Yes")
				exit()
	l += 1
print("No")

Solution (Python):
n, m = map(int, input().split())
a = ['']*n
b = ['']*m
for i in range(n):
  a[i] = str(input())
for i in range(m):
  b[i] = str(input())
for i in range(n-m+2):
  c = a[i:i+m]
  for j in range(n-m+2):
    d = [e[j:j+m] for e in c]
    if b == d:
      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):
        if A[i][j] == B[0][0]:
            flg = True
            for k in range(M):
                if flg:
                    for l in range(M):
                        if A[i+k][j+l] != B[k][l]:
                            flg = False
                            break
            if flg:
                print('Yes')
                quit()
print('No')

Solution (Python):

n, m = list(map(int, input().rstrip().split()))
lst_n = [input().rstrip() for _ in range(n)]
lst_m = [input().rstrip() for _ in range(m)]

for i in range(n - m + 1):
    for j in range(n - m + 1):
        if [lst_n[j + k][i : i + m] for k in range(m)] == lst_m:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")

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

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

B = []
for j 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')
            break
        continue
    else:
        continue
    break
else:
    print('No')

Solution (Python):



def solve():
  N,M = map(int, input().split())
  An = []
  Bn = []
  [An.append(str(input())) for i in range(N)]
  [Bn.append(str(input())) for i in range(M)]

  for i in range(0,N-M+1):
    for j in range(0,N-M+1):
      ret = True
      for k in range(M):
        if An[i+k][j:M+j] != Bn[k]:
          ret = False
      if ret:
        return True
  return False

if __name__ == "__main__":
  if solve():
    print('Yes')
  else:
    print('No')

Solution (Python):
import sys

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

for ai in range(n-m+1):
    for aj in range(n-m+1):
        can = True
        for bi in range(m):
            if a_array[ai+bi][aj:aj+m] != b_array[bi]:
                can = False
                break
        if can:
            print('Yes')
            sys.exit()

print('No')

Solution (Python):
import sys

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

for y in range(N-M+1):
    for x in range(N-M+1):
        for k in range(M):
            if A[y+k][x:x+M] != B[k]:
                break
        else:
            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)]

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

found = False
for i in range(N-M+1):
    for j in range(N-M+1):
        if match(i,j):
            found = True
            
print("Yes") if found 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)]

import sys

for r in range(n - m + 1):
  for c in range(n - m + 1):
    for x in range(m):
      if a[r+x][c:c+m] != b[x][:]:
        break
    else:
      print("Yes")
      sys.exit()

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 y in range(n-m+1):
    for x in range(n-m+1):
        judge = True
        for i in range(m):
            for j in range(m):
                
                
                
                if a[y+i][x+j] != b[i][j]:
                    judge = False
        if judge:
            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)]
ans = "No"
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"
                    break
            if ans == "No":
                break
        if ans == "Yes":
            break
    else:
        continue
    break
print(ans)

Solution (Python):


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

    alist = []
    for i in range(n):
        alist.append(input().strip())

    blist = []
    for i in range(m):
        blist.append(input().strip())

    return n, m, alist, blist




def submit():
    n, m, alist, blist = read_input()

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

            check = True
            for x in range(m):
                for y in range(m):
                    if alist[i + x][j + y] != blist[x][y]:
                        check = False
                        break
                if not check:
                    break

            if check:
                print('Yes')
                return

    print('No')


if __name__ == '__main__':
    submit()

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()
print('No')

Solution (Python):

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

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

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

for i in range(N-M+1):
  for j in range(N-M+1):

    f=True
    for k in range(M):
      for l in range(M):
        if la[i+k][j+l]!=lb[k][l]:
          f=False
    if f:
      print('Yes')
      exit()

print('No')

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

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

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


for x in range(N):
    for y in range(N):
        if x + M > N or y + M > N:
            break

        flag = True
        for tx in range(M):
            for ty in range(M):
                if As[x + tx][y + ty] != Bs[tx][ty]:
                    flag = False

        if flag:
            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)]

def same(x,y):
    for i in range(m):
        for j in range(m):
            if a[x+i][y+j]!=b[i][j]:
                return False
    return True

for x in range (n-m+1):
    for y in range(n - m + 1):
        if same(x,y):
            print('Yes')
            import sys
            sys.exit()
print('No')

Solution (Python):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
f = False
for i in range(N-M+1):
  if f:
    break
  for j in range(N-M+1):
    if f:
      break
    match = True
    for k in range(M):
      if not match:
        break
      for l in range(M):
        if not match:
          break
        if A[i+k][j+l] != B[k][l]:
          match = False
    if match:
      f = True

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

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

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

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

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

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

ans = 'No'
for i in range((N-M+1)**2):
    y = i % (N-M+1)
    x = i // (N-M+1)
    check = True
    for j in range(M**2):
        v = j % M
        h = j // M
        if A[y+v][x+h] != B[v][h]:
            check = False
        if not check:
            break
    if check:
        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)]
print('YNeos'[all(b!=[t[j:j+m] for t in a[i:i+m]]\
                  for i in range(n-m+1) for j in range(n-m+1))::2])

Solution (Python):
def check(i,j):
    for y in range(M):
        for x in range(M):
            if A[i+y][j+x] != B[y][x]:
                return False
    return True
    
[N,M] = list(map(int,input().split()))
A = [input() for i in range(N)]
B = [input() for i in range(M)]
ans = "No"
for i in range(N-M+1):
    for j in range(N-M+1):
        if check(i,j):
            ans = "Yes"
print(ans)

Solution (Python):
import numpy as np

def fn(a, b):
    for i in range(n-m+1):
        for j in range(n-m+1):
            if np.all(b == a[i:m+i,j:m+j]):
                return True
    return False

n, m = [int(i) for i in input().split()]
a = []
for i in range(n):
    res = []
    for j in input():
        if j == ".":
            res.append(1)
        elif j == "
            res.append(0)
    a.append(res)
b = []
for i in range(m):
    res = []
    for j in input():
        if j == ".":
            res.append(1)
        elif j == "
            res.append(0)
    b.append(res)

a = np.array(a)
b = np.array(b)

if fn(a, b):
    print("Yes")
else:
    print("No")

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

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

for b in range(N-M+1):
    for a in range(N-M+1):
        count = 0
        for i in range(M):
            if B[i] == A[i+b][a:a+M]:
                count += 1
        if count == M:
            print('Yes')
            sys.exit()
    
print('No')