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

from itertools import permutations

def match(lt):
    if m == 1:
        rng = [(0, 0)]
    else:
        rng = permutations(range(m), 2)
    for b_x, b_y in rng:
        a_x = lt[0] + b_x
        a_y = lt[1] + b_y
        if a[a_y][a_x] != b[b_y][b_x]:
            return False

    return True

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

flag = 'No'
for i in range(N-M+1):
    for j in range(N-M+1):
        check = []
        for k in range(M):
            if A[i+k][j:j+M] == B[k]:
                check.append(1)
            else:
                check.append(-1)
        if sum(check) == M:
            flag = 'Yes'
print(flag)

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

print("No")

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

B = []
for i in range(M):
    b = str(input())
    b = list(b)
    B.append(b)
    
    
ans = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        X = []
        Y = A[i:M+i]
        for k in range(M):
            x = Y[k][j:M+j]
            X.append(x)
        
        if X == B:
            ans = 1
if ans == 1:
    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)]
ans="No"
for i in range(n-m+1):
    for k in range(n-m+1):
        if b[0]==a[i][k:k+m]:
            if sum([b[l]==a[i+l][k:k+m] for l in range(m)])==m:
                ans="Yes"
                break
print(ans)

Solution (Python):
a,b = map(int,input().split())
lineA = [input() for i in range(a)]
lineB = [input() for i in range(b)]
count = 0
for i in range(b):
    if lineB[i] in lineA[i]:
        count += 1
if count == b:
    print("Yes")
else:
    print("No")

Solution (Python):

import sys


def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N, M = ISI()
A = [IS() for _ in range(N)]
B = [IS() for _ in range(M)]

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


find = False
for i in range(N-M+1):
    for j in range(N-M+1):
        if match(i, j) == True:
            find = True
if find == True:
    print("Yes")
else:
    print("No")

Solution (Python):
n,m=map(int,input().split())
a=[]
for _ in range(n):
    a.append(input())
b=[]
for _ in range(m):
    b.append(input())
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if a[i+k][j:j+m]!=b[k]:
                break
            elif k==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)]
x = y = 0

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

for x in range(n-m+1):
  for y in range(n-m+1):
    if check(x,y):
      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):
        if all([A[i+x][j+y] == B[x][y] for x in range(M) for y in range(M)]):
            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)]
ans=0
for i in range(n-m+1):
  for s in range(n-m+1):
    t = [k[s:s+m] for k in a[i:i+m]]
    if t==b:ans=1
print("Yes") if ans==1 else 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)])
P = np.zeros(B.shape,str)
a = 0
for i in range(n-m+1):
   for j in range(n-m+1):
      P= A[i:i+m,j:j+m]
      if np.all(B==P):
         a = 1
         break

if a ==0:
   print("No")
else:
   print("Yes")

Solution (Python):
import sys
import copy
import string
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, m = na()
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):
        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'
print(ans)

Solution (Python):
from itertools import product

def resolve():
    n,m=map(int,input().split())
    A=[input() for _ in range(n)]
    B=[input() for _ in range(m)]
    flag = any([r[j:j+m] for r in A[i:i+m]]==B for i,j in product(range(n-m+1),range(n-m+1)))
    print("Yes" if flag else "No")
resolve()

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

f = False
ff = False

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 A[i+k][j+l] != B[k][l]:
          f = False
    if f:
      ff = True
      break

if ff:
  print("Yes")
else:
  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 k in range(N-M+1):
  for l in range(N-M+1):
    C = A[k:k+M,l:l+M]
    if (B==C).all():
      print('Yes')
      exit()
print('No')

Solution (Python):
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]
flag = False
for i in range(N-M+1):
    for j in range(N-M+1):
        a = [x[j:j+M] for x in A[i:i+M]]
        if a == B:
            flag = True
print('Yes' if flag == True else '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()
  
A_tmp=[""]*M
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(M):
      A_tmp[k]=A[j+k][i:i+M]
    if A_tmp==B:
      print("Yes")
      exit(0)

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

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

for i in range(n):
    if n < i + m:
        break
    for j in range(n):
        if n < j + m:
            break
        if all(a[j+k][i:i+m] == b[k] for k in range(m)):
            print("Yes")
            exit()
print("No")

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

            c.append(a[i+k][j:j+m])
            if c==b:
                ans='Yes'
                break
print(ans)

Solution (Python):
n,m=map(int,input().split())
a=[];b=[]
flag=False
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):
    c=[]
    for k in range(m):
      c.append(a[i+k][j:j+m])
    if c==b:
      flag=True
      break
print(['No','Yes'][flag])

Solution (Python):
def main():
    N, M = map(int, input().split())
    A = []
    for _ in range(N):
        A.append(input())
    B = []
    for _ in range(M):
        B.append(input())
    for i in range(N-M+1):
        for j in range(N-M+1):
            isMatch = True
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] != B[k][l]:
                        isMatch = False
                        break
            if isMatch:
                return "Yes"
    return "No" 


if __name__ == '__main__':
    print(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 all((A[i+y][j:j+M] == B[y] for y in range(M))):
            print("Yes")
            break
    else:
        continue
    break
else:
    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 i in range(n - m + 1):
    for j in range(n - m + 1):
        valid = True
        for k in range(m):
            for l in range(m):
                if A[i + k][j + l] != B[k][l]:
                    valid = False
                    break
            if valid is False:
                break
        if valid:
            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)]
fl = False
for i in range(n - m + 1):
    if b[0] in a[i]:
        tmp = a[i].find(b[0])
        if m == 1:
            fl = True
        for j in range(1,m):
            if a[i+j][tmp:tmp+m] != b[j]:
                fl = False
                break
            fl = True
    if fl:
        break
if fl:
    print("Yes")
else:
    print("No")

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

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

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

fl = False
for i in range(n-m+1):
    if b[0] in a[i]:
        tmp = a[i].find(b[0])
        if m == 1:
            fl = True
        for j in range(1,m):
            if a[i+j][tmp:tmp+m] != b[j]:
                fl = False
                break
            fl = True
    if fl:
        break
if fl:
    print("Yes")
else:
    print("No")

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

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

cnt = 0
flag = False

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 = True
        else:
            cnt = 0

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

Solution (Python):
def ck(i,j):
  flag = True
  for a, b in zip(A[i:i+M], B):
    for aa, bb in zip(a[j:j+M], b):
      if aa != bb:
        flag = False
  return flag

f = False

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):
    if A[i][j] == B[0][0]:
      if (ck(i,j)):
        f = True
        
if f:
  print("Yes")
else:
  print("No")

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

flag=False
for i in range(n-m+1):
  for j in range(n-m+1):
    if [a[j:j+m] for a in As[i:i+m]]==Bs:
      flag=True

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

Solution (Python):
def main():
    n, m = (int(i) for i in input().split())
    a = [input() for i in range(n)]
    b = [input() for i in range(m)]
    
    equal_flag = False
    k = 0
    for i in range(n):
        for j in range(n-m+1):
            if a[i][j:j+m] == b[k]:
                plus = 1
                while k+plus != m:
                    if i+plus >= n or a[i+plus][j:j+m] != b[k+plus]:
                        break
                    plus += 1
                else:
                    equal_flag = True
        if equal_flag:
            print("Yes")
            break
    else:
        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)]
ans = "No"

for i in range(N - M + 1):
  for j in range(N - M + 1):
    if [a[j:j+M] for a in A[i:i+M]] == B:
      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):
import re

n, m = map(int, input().split())
a = [input().strip() for _ in range(n)]
b = [input().strip() for _ in range(m)]
for idx_a, arow in enumerate(a[:n-m+1]):
  for idx_obj in re.finditer(b[0], arow):
    falg = True
    for i in range(1,m):
      if b[i] != a[idx_a+i][idx_obj.start():idx_obj.end()]:
        falg = False
    if falg is True:
      print('Yes')
      exit()
print('No')

Solution (Python):
import re

n, m = map(int, input().split())
a = [input().strip() for _ in range(n)]
b = [input().strip() for _ in range(m)]
for idx_a, arow in enumerate(a[:n-m+1]):
  for result in re.finditer(b[0], arow):
    falg = True
    for i in range(1,m):
      if b[i] != a[idx_a+i][result.start():result.end()]:
        falg = False
    if falg is True:
      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):
    if [A[k][i:i+m] for k in range(j,j+m)]==B:
      ans="Yes"
      break
print(ans)

Solution (Python):
import sys
n,m=map(int,input().split())
a=[]
b=[]
for x in range(n):
    a.append(input())
for y in range(m):
    b.append(input())
for z in range(n-m+1):
    k=0
    l=0
    for w in range(n-m+1):
        if (a[w])[z:z+m]==b[k]:
            l+=1
            k+=1
            if l==m:
                print('Yes')
                sys.exit()
else:
    print('No')

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

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


for i in range(n-m):
    for j in range(n-m):
        c=0
        for k in range(m):
            if b[k] == a[i+k][j:j+m]:
                c+=1
            else:
                break
        if c==m:
            break
    if c==m:
        break

if a==b:
    print("Yes")
elif n==m:
    print("No")
elif c==m:
    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):
            Flag = True
            if a[i+k][j:j+m] != b[k]:
                Flag = False
                break
        if Flag == True:
            print('Yes')
            exit()

print('No')

Solution (Python):
m,n=[int(x) for x in str(input()).split()]
s=""
for i in range(m+2):
  s+="0"
A=[s]
for i in range(m):
  A.append("0"+input()+"0")
A.append(s)


s=""
for i in range(n+2):
  s+="0"
B=[s]
for j in range(n):
  B.append("0"+input()+"0")
B.append(s)


count=0
for j in range(1,m-n+2):
  for k in range(1,m-n+2):
    ans=1
    for a in range(1,n+1):
      for b in range(1,n+1):
        
        if A[j+a-1][k+b-1]!=B[a][b]:
          ans=0
    if ans==1:
      count=1
if count==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)]
BB = sum(B,[])
for i in range(n-m+1):
  for k in range(n-m+1):
    AA = []
    for v in range(m):
      AA += A[i+v][k:k+m]
    if BB == AA:
      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)]
for i in range(n - m + 1):
  for j in range(n - m + 1):
    isMatch = True
    for k in range(m):
      for l in range(m):
        if a[i + k][j + l] != b[k][l]:
          isMatch = False
    if isMatch == True:
      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):
    for k in range(m):
      if b[k] != a[i+k][j:j+m]:
        break
      if k == m-1:
        print('Yes')
        exit()
print('No')

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

c = []

d = 0

for i in range(N-M+1):
    if d==1:break
    for j in range(N-M+1):
        c = [A[i+k][j:j+M] for k in range(M)]
        if B==c:
            d = 1
            break
if d==1: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):
        ok = True
        for k in range(M):
            if A[i+k][j:j+M] != B[k]:
                ok = False
                break
        if ok:
            print("Yes")
            exit()
print("No")

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

for i in range(M):
  b.append(input())
ans="No"

for i in range(N-M+1):
  for j in range(N-M+1):
    c=[a[k][j:j+M] for k in range(i,i+M)]
    
    if c==b:
      ans="Yes"
print(ans)

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

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

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

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


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


ans = False
for y in range(N-M+1):
  for x in range(N-M+1):
    matched = True
    for v in range(M):
      for u in range(M):
        if A[y+v][x+u]!=B[v][u]:
          matched = False
    if matched:
      ans = True
print('Yes' if ans else 'No')

Solution (Python):
import numpy as np
n, m=map(int,input().split())

n_grid=np.array([list(input()) for _ in range(n)])
m_grid=np.array([list(input()) for _ in range(m)])

found=False
for i in range(n-m+1):
  for j in range(n-m+1):
    if (m_grid == n_grid[i:i+m, j:j+m]).all():
      found=True
      break
if found:
  print("Yes")
else:
  print("No")

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

Solution (Python):
N, M = map(int, input().split())
As = []
for i in range(N):
  A = input()
  As.append(A)
Bs = []
for i in range(M):
  B = input()
  Bs.append(B)
r = False
for p in range(0, N-M+1):
  for q in range(0, N-M+1):
    ok = True
    for i in range(0, M):
      if Bs[i] != As[i+p][q:q+M]:
        ok = False
        break
    if ok:
      r = True
if r:
  print("Yes")
else:
  print("No")

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

A=[list(input()) for _ in range(N)]
B=[list(input()) for _ in range(M)]
offset=N-M
 
for row_offs in range(offset+1):
  for col_offs in range(offset+1):
    is_match=True
    for row in range(M):
      img_row=A[row+row_offs][col_offs:col_offs+M]
      tmp_row=B[row][:]
      if img_row != tmp_row:
        is_match=False
    if is_match:
      print("Yes")
      sys.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)]
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 i in range(n)]
b=[input() for i in range(m)]
r=any([k[j:j+m] for k 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 i in range(n)]
b = [input() for i in range(m)]
ans = 'Yes'
for i in range(n):
    for j in range(m):
        if b[j] not in a[i]:
            ans = 'No'
print(ans)

Solution (Python):

import sys
INF = float("inf")


def yes():
    print("Yes")  


def no():
    print("No")  


def solve(N: int, M: int, A: "List[str]", B: "List[str]"):

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

    no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    A = [next(tokens) for _ in range(N)]  
    B = [next(tokens) for _ in range(M)]  
    solve(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)]
flag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        c = [x[j:j+m] for x in a[i:i+m]]
        if c == b:
            flag = 1
            break
print('Yes') if flag == 1 else print('No')

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

for i in range(N-M+1):
    A_new = A[i:i+M]
    for j in range(N-M+1):
        A_new_new = list(map(lambda n:n[j:j+M], A_new))
        if A_new_new == B:
            print('Yes')
            exit()
print('No')

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

flg = False
if N == 1 and M == 1:
  if input() == input(): flg = True
else:
  A = [(input()) for _ in range(N)]
  B = [(input()) for _ in range(M)]


for i in range(N-M):
  if flg:
    break
  for j in range(N-M):
    if all([A[i+x][j+y] == B[x][y] for x in range(M) for y in range(M)]):
      flg = True
      break
if flg: print ("Yes")
else: print ("No")

Solution (Python):
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""

a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 



    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())
    = [list(list(sys.stdin.readline().rstrip())) for i in range(h)] 


    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  
"""

if __name__ == "__main__":
    n,m = map(int, sys.stdin.readline().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())
al=[input() for _ in range(n)]
bl=[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 bl[k]!=al[i+k][j:j+m]:
                break
        else:
            print('Yes')
            exit()
else:
    print('No')

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 




 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,M = inputMap()
    A = []
    for i in range(N):
        tmp = input()
        A.append(tmp)
        
    B = []
    for i in range(M):
        tmp = input()
        B.append(tmp)
        
    if N < M:
        print("No")
        sys.exit()
        
    if N == M:
        tmp1 = "".join(A)
        tmp2 = "".join(B)
        
        if tmp1 == tmp2:
            print("Yes")
        else:
            print("No")
        sys,exit()
        
    points = []
    AA = copy.deepcopy(A)
    for i,val in enumerate(AA):
        while True:
            tmp = run(val, B[0])
            if tmp != -1 and N-i >= M:
                points.append((i,tmp))
                valval = list(copy.deepcopy(val))
                valval[tmp] = "T"
                val = "".join(valval)
            else:
                break
            
    for i in points:
        lines, point = i
        flg = True
        for j,val in enumerate(B):
            tmp = A[lines+j][point:].find(val)
            if tmp == -1 or tmp != 0:
                flg = False
        
        if flg == True:
            print("Yes")
            sys.exit()
            
    print("No")
    
def run(ss, dd):
    return ss.find(dd)
    
if __name__ == "__main__":
	main()

Solution (Python):
import numpy as np

n,m=map(int,input().split())
a=np.zeros([n,n])
b=np.zeros([m,m])
map_ = {".":1,"

for i in range(n):
  temp = list(input())
  temp = [map_[c] for c in temp]
  a[i,:] = np.array(temp)
  
for i in range(m):
  temp = list(input())
  temp = [map_[c] for c in temp]
  b[i,:] = np.array(temp)

flag=False
for i in range(n-m+1):
  for j in range(n-m+1):
    temp_a = a[i:i+m,j:j+m]
    check=np.sum(temp_a*b,axis=1)
    check=np.sum(check,axis=0)
    if check==m*m:
      flag=True
      break
    else:
      pass
if flag:
  print("Yes")
else:
  print("No")

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

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

diff = n - m
if diff == 0:
    if a == b:
        print('Yes')
    else:
        print('No')
else:
    for i in range(diff + 1):
        for j in range(diff + 1):
            ans = True
            for k in range(m):
                for l in range(m):
                    if b[k][l] != a[i + k][j + l]:
                        ans = False
            if ans:
                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):
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):
        count=0
        for k in range(M):
            for l in range(M):
                if a[i+k][j+l]!=b[k][l]:
                    break
                else:
                    count+=1
        if count==M*M:
            print("Yes")
            exit()
print("No")