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 _ 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 k in range(M):
            for l in range(M):
                if A[i + k][j + l] == B[k][l]:
                    pass
                else:
                    flag = False

        if flag:
            break

    if flag:
        break

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

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

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]:
                    pass
                else:
                    flag = False

        if flag:
            break

    if flag:
        break

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

Solution (Python):
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60


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


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

count=0

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

Solution (Python):
import numpy as np
N, M = map(int, input().split())
A = np.array([list(input()) for i in range(N)])
B = np.array([list(input()) for i 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 = [list(input()) for i in range(n)]
b = [list(input()) for i in range(m)]
def check(x,y):
    ans = True
    for i in range(m):
        for j in range(m):
            if b[i][j] != a[i+x][j+y]:
                ans = False
    return ans

for i in range(n-m+1):
  for j in range(n-m+1):
      if check(i,j):
          print("Yes")
          exit()
print("No")

Solution (Python):
import sys

input = sys.stdin.readline


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

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


if __name__ == '__main__':
    main()

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

ans = 'No'


def check(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 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
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):
        flag = True
        for k in range(m):
            for l in range(m):
                if a[0+i+k, 0+j+l] != b[0+k, 0+l]:
                    flag = False
        if flag:
            break
    if flag:
        break
if flag:
    print('Yes')
else:
    print('No')

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

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

for i in range(N - M + 1):
    for j in range(N - M + 1) :
        for k in range(M) :
            if a_li[i + k][j : j + M] != b_li[k] :
                break
            if k == M - 1:
                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)]
c=[]
ans="No"
for i in range(n-m+1):
    if ans=="Yes":
        break
    else:
        for j in range(n-m+1):
            if ans=="Yes":
                break
            else:
                for k in range(m):
                    c.append(a[i+k][j:j+m])
                if b==c:
                    ans="Yes"
                c=[]
print(ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
A = [list(input()) for i in range(a)]
B = [list(input()) for i in range(b)]

for h in range(a-b+1):
    for w in range(a-b+1):
        count = 0
        for bh in range(b):
            for bw in range(b):
                if A[bh+h][bw+w] == B[bh][bw]:
                    count += 1
        if count == b * b:
            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):
        tmp = []
        for k in a[i:i+m]:
            tmp.append(k[j:j+m])
        if tmp == b:
            print('Yes')
            exit()
print('No')

Solution (Python):
N, M = map(int, input().split())
a = []
b = []
for i in range(N):
    a.append(input())
c = 0
ans = "No"
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]:
                c += 1
        if c == M:
            ans = "Yes"
            break
        c = 0
print(ans)

Solution (Python):
n,m = map(int,input().split())
f = lambda k:[input() for _ in range(k)]
ln,lm = f(n),f(m)
for i in range(n-m+1):
  for j in range(n-m+1):
    lk = [s[j:j+m] for s in ln[i:i+m]]
    if lk==lm:
      print('Yes')
      break
  else:
    continue
  break
else:
  print('No')

Solution (Python):
n,m=map(int,input().split())
a=[[i for i in input()] for l in range(n)]
b=[[i for i in input()] for l in range(m)]
bs=""
for p in b:bs+="".join(p)
s=""
for TopX in range(n-m+1):
    for TopY in range(n-m+1):
        s=""
        for x in range(m):
            for y in range(m):
                s+=a[TopY+y][TopX+x]
        if bs==s:
            print("Yes")
            exit(0)
print("No")

Solution (Python):
N, M = map(int, input().split())
a = []
b = []
for i in range(N):
    a.append(input())
c = 0
ans = "No"
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]:
                c += 1
        if c == M:
            ans = "Yes"
            break
        c = 0
print(ans)

Solution (Python):
N,M=map(int,input().split())
A=[]
for i in range(N):
    a=input()
    A.append(a)
B=[]
for i in range(M):
    b=input()
    B.append(b)
a=""
b=""
for i in range(M):
    b=b+B[i]
l=[]
for i in range(N):
    if (i+M)>N:
        break
    for j in range(N):
        if (j+M)>N:
            break
        c=""
        for n in range(i,i+M):
            for m in range(j,j+M):
                    c+=A[n][m]
        l.append(c)
ok=False

for i in range(len(l)):
    if b==l[i]:
        ok=True
if ok:
    print("Yes")
else:
    print("No")

Solution (Python):
n, m = map(int, input().split())
a = []
b = []
c = n - m + 1
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())
ans = 'No'
for i in range(c):
    for j in range(c):
        flag = 0
        for k in range(m):
            if b[k] == a[i + k][j:j + m]:
                flag += 1
        if flag == 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)]
def F(a,b):
  for k in range(M):
    for l in range(M):
      if A[a+l][b+k]!=B[l][k]:
        return False
  return True
  
for i in range(N-M+1):
  for j in range(N-M+1):
    if F(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)]

count=0
ep=0
flag=0
for i in range(0,N-M+1,1):
    for j in range(0,N-M+1,1):
        for k in range(0,M,1):
            for l in range(0,M,1):
                if A[i+k][j+l]==B[k][l]:
                    count=count+1
        
        
        if count==M*M:
            flag=1
            break
        count=0

if flag==1:
    print("Yes")
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)]

fl = False
for i in range(N-M+1):
    for j in range(N-M+1):
        
        
        
        
        if b==[a[k+i][j:j+M] for k in range(M)]:
            fl = True
print('Yes') if fl else print('No')

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

    i = 0
    j = 0
    snipped = []
    while i + M <= N:
        for di in range(M):
            snipped.append(A[i+di][j:M+j])
        if B == snipped:
            print('Yes')
            break

        snipped = []
        j += 1
        if j + M > N:
            i += 1
            j = 0
    else:
        print('No')

    
if __name__ == '__main__':
    solve()

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

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

for i in range(n-m+1):
    for j in range(n-m+1):
        if solve(i,j):
            print("Yes")
            exit()
print("No")

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

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

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

flag1 = False
for ax in range(n-m+1):
    for ay in range(n-m+1):

        flag2 = True
        for bx in range(m):
            for by in range(m):
                if al[ax+bx][ay+by] != bl[bx][by]:
                    flag2 = False
        if flag2:
            flag1 = True

if flag1:
    print("Yes")
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))
b = len(B[0])

ans = "No"
for i in range(N-(M-1)):
  n = -1
  c = 0
  for j in range(M):
    if B[j] in A[i+j]:
      if n < 0:
        n = A[i + j].index(B[j])
        c += 1
      else:
        if B[j] in A[i + j][n: n + b + 1]:
          c += 1
  if c == M:
    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 = [input() for  _ in range(n)]
b = [input() for  _ in range(m)]

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

def is_same(i,j):
  for l in range(m):
    for k in range(m):
      if a[i+l][j+k] != b[l][k]:
        return False
  return True
  
for i in range(n-m+1):
  for j in range(n-m+1):
    if is_same(i,j):
      print('Yes')
      exit()
print('No')

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

resolve()

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

resolve()

Solution (Python):


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

AN=[]
for _ in range(N):
    AN.append(list(input()))
    


AM=[]
for _ in range(M):
    AM.append(list(input()))


for i in range(N-M+1):
    for j in range(N-M+1):
        
        flag=True
        for k in range(M):
            if AN[i+k][j:j+M]!=AM[k]:
                
                flag=False
        if flag:
            print("Yes")
            exit()
        
print("No")

Solution (Python):
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
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):




def main():
    N, M = list(map(int, input().split()))
    A = [input() for _ in range(N)]
    B = [input() for _ in range(M)]
    for i in range((N - M + 1) ** 2):
        y = i // (N - M + 1)
        x = i % (N - M + 1)
        for j in range(M):
            if B[j] != A[y + j][x:x + M]:
                break
        else:
            print('Yes')
            break
    else:
        print('No')


if __name__ == "__main__":
    main()

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

list_Count = []
answer = "No"
for j in range(n - m + 1):
    
    for i in range(n - m + 1):
        if m == 1 and list_a[j][i:m+i] == list_b[0]: answer = "Yes"
        elif list_a[j][i:m+i] == list_b[0]: 
            list_Count.append([i, j])

for id in range(len(list_Count)):
    for x in range(m - 1):
        if list_a[list_Count[id][1] + x + 1][list_Count[id][0] : m+ list_Count[id][0]] != list_b[x + 1]: break
        elif x + 1 ==  m - 1: answer = "Yes"

print(answer)

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 AB(h,w):
  ret=[[None]*M for i in range(M)]
  for i in range(M):
    for j in range(M):
      ret[i][j]=A[h+i][w+j]
  return ret
ans='No'
for h in range(N-M+1):
  for w in range(N-M+1):
    if AB(h,w)==B:
      ans='Yes'
      break
print(ans)

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

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

Solution (Python):
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 iy in range(n-m+1):
    for ix in range(n-m+1):
        bflag=True
        for jy in range(m):
            for jx in range(m):

                if(a[iy+jy][ix+jx] != b[jy][jx]):
                    bflag=False
                    break
            if(not bflag):
                break
        else:
            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 check(x, y):
    for i in range(M):
        for j in range(M):
            if A[x + i][y + j] == B[i][j]:
                continue
            else:
                return False
    return True
if A == B:
    print("Yes")
    exit()
for x in range(N - M):
    for y in range(N - M):
        if check(x, y):
            print("Yes")
            exit()
print("No")

Solution (Python):

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

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

a = []
for i in range(0, n):
    a.append(input())

b = []
for i in range(0, m):
    b.append(input())

def same(a, b, i, j):
    for k in range(0, len(b)):
        if a[i + k][j:j + len(b)] != b[k]:
            return False
    return True

is_same = False
for i in range(0, n - m + 1):
    for j in range(0, n - m + 1):
        if same(a, b, i, j):
            is_same = True
            break
    else:
        continue
    break

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

Solution (Python):
import itertools
import sys

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

for i, j in itertools.product(range(n - m + 1), range(n - m + 1)):
	if a[i][j] == b[0][0]:
		for p, q in itertools.product(range(m), range(m)):
			if a[i + p][j + q] != b[p][q]:
				if i == n - m and j == n - m:
					print('No')
				break
			elif p == m - 1 and q == m - 1:
				print('Yes')
				sys.exit()
				
	elif i == n - m and j == n - m:
		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)]

def bina(A , B):
    for i in range((N-M)+1):
        for w in range(N):
            c = []
            for q in range(M):
                c += [A[i+q][w:w+M]]
            if c == B:
                return "Yes"
    return "No"

if __name__ == '__main__':
    ans = bina(A , B)
    print(ans)

Solution (Python):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
b = any(all(A[i+k][j+l]==B[k][l] for k in range(M) for l in range(M)) for i in range(N-M+1) for j in range(N-M+1))
print("YNeos"[not b::2])

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

if m==1:
    for i in a:
        if b[0] in i:
            print('Yes')
            exit()
        else:
            print('No')
            exit()

for i in range(n-m+1):
    cnt=0
    while cnt<n-m+1:
        l=[]
        for j in range(m):
        
            l+=[a[j+cnt][i:i+m]]

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

Solution (Python):
def solve(n, m, A, B):
    if n == m:
        if all(a == b for a, b in zip(A, B)):
            return 'Yes'
        else:
            return 'No'
    for i in range(len(A) - len(B)):
        for j in range(len(A[0]) - len(B[0])):
            if all(a[j:j + len(B[0])] == b for a, b in zip(A[i:i + len(B)], B)):
                return 'Yes'
    return 'No'

_n, _m = map(int, input().split())
_A = [input() for _ in range(_n)]
_B = [input() for _ in range(_m)]
print(solve(_n, _m, _A, _B))

Solution (Python):
import sys

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):
        matched = True

        for k in range(M):
            if A[i+k][j:j+M] == B[k]:
                continue
            else:
                matched = False
                break
    
        if matched:
            print('Yes')
            sys.exit()

print('No')

Solution (Python):
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        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 not flag:
                break
        if flag:
            print('Yes')
            exit()
print('No')

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

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

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

        flg = True
        for ii in range(m):
            for jj in range(m):
                if a[i+ii][j+jj] != b[ii][jj]:
                    flg = False

        if flg == True:
            print('Yes')
            exit()
print('No')

Solution (Python):
n, m = map(int,input().split())
a = [None]*n
b = [None]*m
for i in range(n):
  a[i] = input()
for j in range(m):
  b[j] = input()
r = 'No'
for i in range(n - m + 1):
  end_yoko = i + m
  a_t = [s[i:end_yoko] for s in a]
  for j in range(n - m + 1):
    end_tate = j + m
    if a_t[j:end_tate] == b:
      r = 'Yes'
print(r)

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

    Ai = []
    for _ in range(N):
        Ai.append(input())
    Bi = []
    for _ in range(M):
         Bi.append(input())

    return N, M, Ai, Bi


def solve(N, M, Ai, Bi):
    for xi in range(N - M + 1):
        if Ai[0][xi:xi + M] == Bi[0][:]:
            for yi in range(1, M):
                if not Ai[yi][xi:xi + M] == Bi[yi][:]:
                    break
            return True

    return False


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

Solution (Python):
n,m=map(int,input().split())
s=[input() for _ in range(n)]
t=[input() for _ in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    f=True
    for x in range(m):
      for y in range(m):
        if t[x][y]!=s[x+i][y+j]:
          f=False
          break
      if f is False:
        break
    if f:
      break
  if f:
    print("Yes")
    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 a:
    for j in b:
        if j not in i:
            print("No")
            quit()
print("Yes")

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):
        tmp = []
        for k in a[i:i+m]:
            tmp.append(k[j:j+m])
        if tmp == b:
            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)]

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

for i in range(N-M+1):
  for j in range(N-M+1):
    r=f(i, j)
    if r==True:
      print('Yes')
      exit()
print('No')

Solution (Python):
def is_same(si, sj):
    for i in range(M):
        for j in range(M):
            if gridsA[sj + j][si + i] != gridsB[j][i]:
                return False
    return True


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

if N == M:
    if is_same(0, 0):
        print('Yes')
    else:
        print('No')
else:
    for i in range(N - M):
        for j in range(N - M):
            if is_same(i, j):
                print('Yes')
                exit()
    print('No')

Solution (Python):
n, m = map(int, input().split())
a = []
b = []
for _ in range(n):
    a.append(input())
for _ in range(m):
    b.append(input())
flag = 0
cnt = 0
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]:
                cnt += 1
        if cnt == m:
            flag = 1
        cnt = 0
if flag == 1:
    print('Yes')
else:
    print('No')

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

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)])
flg = 0
for i in range(n-m+1):
  for j in range(n-m+1):
    if (a[i:i+m,j:j+m] == b).all():
      flg = 1
print("Yes" if flg == 1 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 = 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 == True else "No")

Solution (Python):
import numpy as np
import sys
n,m=map(int,input().split())
a= [list(input()) for i in range(n)] 
b= [list(input()) for i in range(m)] 
na=np.array(a)

sa=n-m+1

for x in range(sa):
    for y in range(sa):

        if na[x:x+m,y:y+m].tolist()==b:
            print("Yes")
            sys.exit()
print("No")

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    A=[]
    B=[]
    flg=0
    for i in range(n):
        A.append(STR())
    for i in range(m):
        B.append(STR())
    
    for i in range(n-m+1):
        for j in range(n-m+1):
            if A[i][j:j+m] == B[0]:
                temp=1
                for k in range(1,m):
                    if A[i+k][j:j+m] != B[k]:
                        temp=0
                if temp==1:
                    flg=1
    if flg==1:
        print('Yes')
    else:
        print('No')
    
    
if __name__ == '__main__':
    do()

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