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)]

ans="No"

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:
            ans="Yes"
            break

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())
  
ans = False
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
    if flag:
      ans = True

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

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

for i in range(n - m + 1):
    for j in range(n - m + 1):
        ok = True
        for h in range(m):
            if not ok:
                break
            for w in range(m):
                
                if A[i + h][j + w] != B[h][w]:
                    ok = False
                    break
        if ok:
            print("Yes")
            exit()
print("No")

Solution (Python):
import sys


N, M = [int(x) for x in 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):
        found = True
        for _i in range(M):
            for _j in range(M):
                if A[i + _i][j + _j] != B[_i][_j]:
                    found = False
                    break
            if not found:
                break
        if found:
            print('Yes')
            sys.exit()
print('No')

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

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

ans = False
for i in range(n - m + 1):
  for j in range(n - m + 1):
    for k in range(m):
      ll = ma[i + k][j : j + m]
      if ll != t[k]:
        break
    else:
      ans = True

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

Solution (Python):
from typing import List


def answer(n: int, m: int, a: List[str], b: List[str]) -> str:
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            if a[i][j:j + m] == b[0]:
                matched_lines = 1
                for k in range(1, m):
                    if a[i + k][j:j + m] == b[k]:
                        matched_lines += 1
                    else:
                        break
                if matched_lines == m:
                    return 'Yes'

    return 'No'


def main():
    n, m = map(int, input().split())
    a = [input() for _ in range(n)]
    b = [input() for _ in range(m)]
    print(answer(n, m, a, b))


if __name__ == '__main__':
    main()

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

Solution (Python):


def main():
    n, m = map(int, input().split())
    a = ['' for i in range(n)]
    b = ['' for i in range(m)]
    for i in range(n):
        a[i] = input()
    for i in range(m):
        b[i] = input()
    for i1 in range(n - m + 1):
        for i2 in range(n - m + 1):
            fl = True
            for j in range(m):
                for k in range(m):
                    if a[i1 + j][i2 + k] != b[j][k]:
                        fl = False
            if fl:
                print("Yes")
                exit(0)
    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"
for i in range(n-m+1):
  for j in range(n-m+1):
    if [line[j:j+m] for line in a[i:i+m]]==b:
      ans="Yes"
      break
  if 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):
    for k in range(m):
      
      if a[i+k][j:j+m] != b[k]:
        break
    else:
      print('Yes')
      exit()
print('No')

Solution (Python):
n,m=map(int,input().split())
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 = True
    for k in range(m):
      if A[k+j][i:i+m] != B[k][:]:
        flag = False
        break
    if flag:
      print("Yes")
      quit()
else:
  print("No")

Solution (Python):
n,m=map(int,input().split())
a=[list(input()) for i in range(n)]
b=[list(input()) for i in range(m)]
exist=False
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[i+k][j+l]!=b[k][l]:
          match=False
    if match:
      exist=True
print("Yes" if exist 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):
    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:
            ans = "Yes"
            break
print(ans)

Solution (Python):
import sys












stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n,m = map(int, stdin.readline().rstrip().split())
    
    
    a = [stdin.readline().rstrip() for _ in range(n)]
    b = [stdin.readline().rstrip() for _ in range(m)]

    for i in range(n-m+1):
        for j in range(n-m+1):
            flag = True
            for h in range(m):
                if a[i+h][j:j+m] != b[h]:
                    flag = False
                    break
            if flag == True:
                print("Yes")
                exit()
    print("No")






if __name__ == '__main__':
    solve()

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

Solution (Python):
lst = input().split()
N = int(lst[0])
M = int(lst[1])

A = []
B = []

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

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

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

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

for i in range(n-m+1):
  if B[i] in A[i]:
    for j in range(m-1):
      if B[i+j] not in B[i+j]:
        print("No")
        exit()
    print("Yes")
    exit()
  else:
    print("No")
    exit()

Solution (Python):
from sys import exit
n, m = map(int, input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]
for x, a in enumerate(A):
    if x > n - m + 1:
        break
    for i in range(n - m + 1):
        if a[i: i + m] == B[0]:
            for j in range(m):
                if A[x + j][i: i + m] != B[j]:
                    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)]

ans = "No"
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:
            ans = "Yes"
            break
print(ans)

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

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

idx = [0, 0]
while True:
    if idx[0] == N - 1 and idx[1] == N - 1:
        break
    if A[idx[0]][idx[1]] == B[0][0]:
        check = False
        for i in range(M):
            for j in range(M):
                if 0 <= idx[0] + i < N and 0 <= idx[1] + j < N:
                    if A[idx[0] + i][idx[1] + j] != B[i][j]:
                        check = True
                        break
                else:
                    check = True
                    break
            if check:
                break

        if not check:
            print('Yes')
            exit()
    if idx[1] < N - 1:
        idx[1] += 1
        continue
    else:
        idx[0] += 1
        idx[1] = 1
        continue

if A[-1][-1] == B[0][0] and M == 1:
    print('Yes')
    exit()

print('No')

Solution (Python):
N,M=map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
 
for i in range(N-M+1):
  for j in range(N-M+1):
    t = True
    for k in range(M):
      if B[k] != A[i+k][j:j+M]:
        t = False
    if t:
      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)]
 
flag = False
for i in range(n-m+1):
    for j in range(n-m+1):
        flag = True
        for k in range(m):
            if B[k] != A[i+k][j:j+m]:
                flag = False
        if flag:
            print("Yes")
            exit()
print("No")

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

for i in range(N - M + 1):
    for j in range(N - M + 1):
        same = 0
        for k in range(M):
            if A[i + k][j: j + M] == B[k]:
                same += 1
            else:
                break
        if same == M:
            clear = 1
            break

if clear == 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)]

check = False

for i in range(N-M+1):
  for j in range(N-M+1):
    if A[i][j:j+M] == B[0]:
      flag = True
      for k in range(1,M):
        if A[i+k][j:j+M] != B[k]:
          flag = False
      if flag:
        check = True

print("Yes" if check 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())
for i in range(n-m+1):
  if b[i] in a[i]:
    for x in range(m-1):
      if b[i+x] not in a[i+x]:
        print("No")
        exit()
    print("Yes")
    exit()
  else:
    print("No")
    exit()

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 = []
b = []
for _ in range(n):
  a.append(input())
for _ in range(m):
  b.append(input())

def detect(i, j):
  flag = True
  for k in range(len(b)):
    for l in range(len(b)):
      if i+k >= n or j+l >= n or a[i+k][j+l] != b[k][l]:
        flag = False
        break
    if not flag:
      break
  return flag
  
ans = "No"
for i in range(len(a)):
  for j in range(len(a)):
    if detect(i, j):
      ans = "Yes"
      break
  if 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)]

success = 0
for i in range(n - m + 1):
    fail = 0
    for j in range(n - m + 1):
        fail = 0
        for ii in range(m):
            for jj in range(m):
                if b[ii][jj] == a[i + ii][j + jj]:
                    continue
                else:
                    fail = 1
                    break
            if fail == 1:
                break
        else:
            success = 1
            print('Yes')
            break
    if success == 1:
        break
else:
    if fail == 1:
        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):
        flg = True
        for k in range(M):
            for l in range(M):
                flg = flg & (B[k][l] == A[i+k][j+l])
        
        if flg:
            ans = 'Yes'
            print(ans)
            exit()

ans = 'No'
print(ans)

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()

match_cnt = 0
for i in range(N - M + 1):
    for j in range(N - M + 1):
        flag = True
        for y in range(M):
            if A[y + i][j:j + M] != B[y]:
                flag = False
        if flag:
            match_cnt += 1

if match_cnt > 0:
    print('Yes')
else:
    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()

match_cnt = 0
for i in range(N - M + 1):
    for j in range(N - M + 1):
        flag = True
        for y in range(M):
            for x in range(M):
                if A[y + i][x + j] != B[y][x]:
                    flag = False
        if flag:
            match_cnt += 1

if match_cnt > 0:
    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)]
print('Yes'if any([A[i+k][j:j+M]for k in range(M)]==B for i in range(N-M+1)for j in range(N-M+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)]
for i in range(N-M+1):
    for j in range(N-M+1):
        c = 1
        for k in range(M):
            if A[i+k][j:j+M] != B[k]:
                c = 0
        if c:
            print('Yes')
            exit()
print('No')

Solution (Python):
N,M=map(int,input().split())
A=list(list(input()) for _ in range(N))
B=list(list(input()) for _ in range(M))
flag=False
for i in range(0,N-M+1):
    for j in range(0,N-M+1):
        sub=True
        for x in range(0,M):
            for y in range(0,M):
                if A[i+x][j+y]!=B[x][y]:
                    sub=False
        flag=flag or sub
if flag:
    print("Yes")
else:
    print("No")

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

Solution (Python):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n,m = I()
a = []
b = []

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

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

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]

N,M=mint()
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for x in range(N-M+1):
    for y in range(N-M+1):
        tmp=True
        for i,j in product(range(M),repeat=2):
            if A[x+i][y+j]!=B[i][j]:
                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)]

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

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    N,M = i_map()
    a = [s_input() for _ in range(N)]
    b = [s_input() for _ in range(M)]

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

            for x in range(M):
                for y in range(M):
                    if b[x][y] != a[i+x][j+y]:
                        flg = False
                        break
                if flg == False:
                    break
            if flg == True:
                print("Yes")
                exit()
    print("No")

if __name__=="__main__":
    main()

Solution (Python):
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        if b[0][0] == a[i][j]:
            cnt = 0
            for x in range(m):
                flag = True
                if flag == False:
                    break
                for y in range(m):
                    if b[x][y] == a[i+x][j+y]:
                        cnt += 1
                        pass
                    else:
                        flag = False
                        break
                    if cnt == m**2:
                        print("Yes")
                        exit()
print("No")

Solution (Python):

import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import copy
import math
sys.setrecursionlimit(10**6)




def zz(): return list(map(int, sys.stdin.readline().split()))


def z(): return int(sys.stdin.readline())


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


def C(line): return [sys.stdin.readline() for _ in range(line)]


N, M = zz()
A = [S() for i in range(N)]
B = [S() for i in range(M)]


def check(lis_a, lis_b):
    for a, b in zip(lis_a, lis_b):
        
        if (a != b):
            return False
    return True


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

Solution (Python):
import numpy

n,m = map(int,input().split())
a = numpy.zeros([n,n], dtype=int)
b = numpy.zeros([m,m], dtype=int)
for i in range(n):
    s = input()
    for j in range(n):
        if s[j] == "
            a[i,j] = 1
for i in range(m):
    s = input()
    for j in range(m):
        if s[j] == "
            b[i,j] = 1

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

flag = False
for i in range(n-m+1):
    for j in range(n-m+1):
        flag = True
        for k in range(m):
            if B[k] != A[i+k][j:j+m]:
                flag = False
        if flag:
            print("Yes")
            exit()
print("No")

Solution (Python):

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

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

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


if __name__ == '__main__':
    main()

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

if m == 1:
    for i in a:
        if b[0] in i:
            res = "Yes"
else:
    for k in range(n-m+1): 
        if b[0] in a[k]: 
            for l in range(n-m+1): 
                if b[0] == a[k][l:m+l]: 
                    cnt = 0
                    for o in range(m-1): 
                        if b[o+1] == a[k+o+1][l:m+l]: 
                            cnt += 1
                    if cnt == m-1:
                        res = "Yes"
        
print(res)

Solution (Python):
n,m = map(int, input().split())
a = [[] for _ in range(n)]
b = ""
c = ""
ans = 0
for i in range(n):
  a[i] = list(input())
for j in range(m):
  b += input()
for i in range(n-m+1):
  for j in range(n-m+1):
    for k in range(i,i+m):
      for l in range(j,j+m):
        c += a[k][l]
    if c == b:
      ans += 1
      break
    c = ""
print("Yes" if ans > 0 else "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 sx, sy in product(range(N-M+1), repeat=2):
    is_ok = 1
    for x in range(sx, sx+M):
        for y in range(sy, sy+M):
            if B[x-sx][y-sy] != A[x][y]:
                is_ok=0
                break
        if not is_ok:
            break
    if is_ok:
        print("Yes")
        exit()

print("No")

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

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


n, m = rm()
a = [rr() for _ in range(n)]
b = [rr() for _ in range(m)] 
for i in range(n-m+1):
    for j in range(n-m+1):
        c = [s[j:j+m] for s in a[i:i+m]]
        if c == b:
            print('Yes')
            exit()
print('No')

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

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

for i in R:
    for j in R:
        for k in range(M):
            if A[j+k][i:i+M] != B[k]:
                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)]
for y in range(N - M + 1):
    for x in range(N - M + 1):
        matched = True
        for yy in range(y, y + M):
            for xx in range(x, x + M):
                if A[yy][xx] != B[yy - y][xx - x]:
                    matched = False
                if not matched:
                    break
            if not matched:
                break
        if matched:
            print('Yes')
            exit(0)
print('No')

Solution (Python):
import sys
n,m = map(int,input().split())
la = [input() for _ in range(n)]
lb = [input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        cnt = 0
        for k in range(m):
            for l in range(m):
                if la[i+k][j+l] == lb[k][l]:
                    cnt += 1
        if cnt == m**2:
            print("Yes")
            sys.exit()
print("No")

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

ans = 'No'
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if all([A[i + k][j:j + m] == B[k] for k in range(m)]):
            ans = 'Yes'
print(ans)

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

Solution (Python):
import math
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, math.ceil(N/M)):
    for j in range(0, math.ceil(N/M)):
        
        flag = True
        for l in range(0, M):
            for m in range(0, M):
                if A[l+i][m+j] != B[l][m]:
                    flag = False
                    break
        if flag == True:
            print("Yes")
            exit()
print("No")

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

wa = len(A[0])
wb = len(B[0])
  
matched = False
for i1 in range(N - M + 1):
  for j1 in range(wa - wb +1):
    cnt = 0
    for i2 in range(M):
      
      if B[i2] == A[i1+i2][j1:j1+wb]:
        cnt += 1
    if cnt == M:
      matched = True
      break
          

if matched:
  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):
    flag = True
    AA = [a[j:j+M] for a in A[i:i+M]]
    for a, b in zip(AA, B):
      if a != b:
        flag = False
    if flag:
      print("Yes")
      exit()
print("No")

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

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

        count = 0
        if a_lst[i][j] == b_lst[0][0]:
            for k in range(m):
                for l in range(m):
                    if a_lst[i + k][j + l] == b_lst[k][l]:
                        count += 1

            if count == m ** 2:
                flag = True

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