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

for x in range(N-M+1):
  for y in range(N-M+1):
    t=1
    for i in range(M):
      for j in range(M):
        if A[x+i][y+j]!=B[i][j]:
          t=0
    if t==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)]
 
ans=0        
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=1
        
        
if ans == 1:
    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 y in range(N - M + 1):
    for x in range(N - M + 1):
        mc = 0
        for i in range(M):
            for j in range(M):
                if A[y + i][x + j] == B[i][j]:
                    mc += 1
                else:
                    break
            else:
                continue
            break
        if mc == M * M:
            print("Yes")
            exit()
print("No")

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

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

Solution (Python):
n,m=map(int,input().split())
l=[]
for i in range(n):
    l.append(list(input()))
k=[]
for i in range(m):
    k.append(list(input()))
f=0
for i in range(n-m+1):
    for j in range(n-m+1):
        t=0
        for p in range(m):
            for q in range(m):
                if k[p][q]==l[i+p][j+q]:
                    t+=1
        if t==m*m:
            f+=1
if f>0:
    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)]


for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j] == B[0][0]:
            for x in range(M):
                ta = A[i][j:j+M:]
                if ta != B[x]:
                    break
                i += 1
            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):
      for l in range(m):
        if a[i+k][j+l]!=b[k][l]:
          flag=False
          break
      if flag==False:
        break
    if flag:
      print("Yes")
      exit()
        
print("No")

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

A=[input() for i in range(n)]
B=[input() for i in range(m)]

ans=0        
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=1
        
        
if ans == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
from itertools import permutations
def main():
  n, m = map(int, input().split())
  a=[]
  for i in range(n):
    a.append(input())
  b = ""
  for j in range(m):
    b += input()
  for i in range(n - m + 1):
    for j in range(n - m + 1):
      x = ""
      for k in range(m):
        x += a[j+k][i: i + m]
      if b == x:
        print("Yes")
        return
  print("No")
main()

Solution (Python):
n,m=map(int,input().split())
a=[input()for _ in range(n)]
b=[input()for _ in range(m)]
x=n-~-m
C=0
for i in range(x):
    for j in range(x):
        c=0
        for k in range(m):
            if a[i+k][j:j+m]==b[k]:
                c+=1
        if c==m:
            C+=1
print('YNeos'[C<1::2])

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):
        for k in range(m):
            for l in range(m):
                if A[i+k][j+l] == B[k][l]:
                    flag = True
                else:
                    flag = False
                    break
    if k == m-1 and l == m-1 and 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 a:
  for j in b:
    if j not in i:
      print("No")
      quit()
print("Yes")

Solution (Python):
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
A = [stdin.readline().rstrip() for n in range(N)]
B = [stdin.readline().rstrip() for m in range(M)]
for i in range(N-M+1):
  for j in range(N-M+1):
    tmp = [a[j:j+M] for a in A[i:i+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)]
c = any([c[j:j+m] for c in a[i:i+m]] == b
        for j in range(n-m+1) for i in range(n-m+1))
print('Yes' if c 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):
    for j in range(n):
        if a[i][j] == b[0][0]:
            if j+m <= n and i+m <= n:
                if [a[i+k][j:j+m] for k in range(m)] == b:
                    print('Yes')
                    exit()
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)]

for i in range(n):
    for j in range(n):
        if j+m <= n and i+m <= n:
            if [a[i+k][j:j+m] for k in range(m)] == b:
                print('Yes')
                exit()
else:
    print('No')

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

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

for i in range(N-M+1):
  l = 0
  for _ in range(A[i].count(B[0])):
    l = A[i].index(B[0], l)
    result = True
    for k in range(1, M):
      if B[k] != A[i+k][l:l+len(B[k])]:
        result = False
        break
    if result:
      print("Yes")
      exit()
    l += 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 _ in range(A[i].count(B[0])):
    l = A[i].index(B[0])
    result = True
    for k in range(1, M):
      if B[k] != A[i+k][l:l+len(B[k])]:
        result = False
        break
    if result:
      print("Yes")
      exit()
    l += 1
      
print("No")

Solution (Python):
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
import sys
for a in A:
    for b in B:
        if b not in a:
            print('No')
            sys.exit()
print('Yes')

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

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

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

Solution (Python):
N,M=map(int,input().split())
A=[input() for n in range(N)]
B=[input() for m in range(M)]
wb=len(B[0])
hb=len(B)
for h in range(len(A)-hb+1):
    for w in range(len(A[0])-wb+1):
        f=True
        for b in range(hb):
            if A[h+b][w:w+wb] != B[b]:
                f=False
                break
        if f:
            print('Yes')
            exit()
print('No')

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    a = [list(str(input().rstrip('\n'))) for _ in range(n)]
    b = [list(str(input().rstrip('\n'))) for _ in range(m)]
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            b_y = True
            for k in range(i, i + m):
                for l in range(j, j + m):
                    if a[k][l] != b[k-i][l-j]:
                        b_y = False
                        break
            if b_y:
                print("Yes")
                exit()
    print("No")


if __name__ == '__main__':
    slove()

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

for i in range(n - m + 1):
  for j in range(n - m + 1):
    temp = 0
    for k, one_b in enumerate(list_b):
      if one_b == list_a[j+k][i:(i+m)]:
        temp += 1
      else:
        break
    if temp == m:
      print("Yes")
      exit()
print("No")

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

def create_coords(x, y, l):
    return [(_x, _y) for _x in range(x, x + l) 
                     for _y in range(y, y + l)]

def concat(li, coords):
    return ''.join(map(lambda c: li[c[0]][c[1]], coords))

def main():
    ans = 'No'
    r = range(N - M + 1)
    l = M
    b = concat(B, create_coords(0, 0, l))
    for x in r:
        for y in r:
            a = concat(A, create_coords(x, y, l))
            if a == b:
                ans = 'Yes'
                break
    print(ans)

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):
    if b[0] in a[i]:
        x=a[i].index(b[0])
        st=0
        for j in range(1,m):
            for k in range(m):
                if a[i+j][x+k]!=b[j][k]:
                    st=1
                    break
        if st==0:
            print('Yes')
            exit()
print('No')

Solution (Python):
import sys
n, m = map(int, input().split())
a_list = sum([input().split() for i in range(n)], [])
b_list = sum([input().split() for i in range(m)], [])
for b in b_list:
    for a in a_list:
        if b not in a:
            print('No')
            sys.exit()
print('Yes')

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

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

point=0

for nx in range(N-M+1):
  for ny in range(N-M+1):
    ans=[a[ny:ny+M] for a in A[nx:nx+M]]
    if ans == B:
      point+=1

if point==0:
  print('No')
else:
  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): 
  c = a[i].find(b[0]) 
  if c != -1:
    for k in range(m-1):
      if a[i+k+1][c:c+m] != b[k+1]:
        break
    else:
      print("Yes")
      break
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):
        for k in range(m):
            for l in range(m):
                if a[k + i][l + j] != b[k][l]:
                    break
            else:
                continue
            break
        else:
            print('Yes')
            exit()
print('No')

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

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

Solution (Python):
n,m = map(int,input().split())
a = []
for i in range(n):
    a0 = list(input())
    a.append(a0)
b = []
for i in range(m):
    b0 = list(input())
    b.append(b0)
now = [0,0]
ans = "No"
count = 0
while now[0] <= n-m and now[1] <= n-m:
    
    if a[now[0] + count//m][now[1]+count%m] == b[count//m][count%m]:
        count += 1
    else:
        count = 0
        if now[1] < n-m:
            now[1] += 1
        else:
            now[1] = 0
            now[0] += 1
    if count == m*m:
        ans = "Yes"
        break
print(ans)

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):
        for k in range(M):
            for l in range(M):
                if A[k + i][l + j] != B[k][l]:
                    break
            else:
                continue
            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 i in range(n - m + 1):
    for j in range(n - m + 1):
        tmp = 0
        for k in range(m):
            for l in range(m):
                if a[i + k][j + l] == b[k][l]:
                    tmp += 1
        if tmp == m ** 2:
            print("Yes")
            exit()
print("No")

Solution (Python):
N, M = tuple(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 y in range(M):
            for x in range(M):
                if A[i+y][j+x] != B[y][x]:
                    flag = False
        if flag:
            print("Yes")
            exit()
print("No")

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


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

    for i in range(N-M+1):
        for j in range(N-M+1):
            flg = True
            for y in range(M):
                for x in range(M):
                    if A[i+y][j+x]!=B[y][x]:
                        flg = False
            if flg:
                print('Yes')
                return
    print('No')
    
    

if __name__ == '__main__':
    main()

Solution (Python):
import sys
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 l in range(N - M + 1):
        if A[i][l:l+M] == B[0]:
            for q in range(M):
                if A[i+q][l:l+M] != B[q]:
                    break
                if q == M-1:
                    print("Yes")
                    sys.exit()
print("No")

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

for p in range(n): 
    for q in range(n): 
        
        
        
        
        if p+m-1 < n and q+m-1 < n and all(all( a[p+i][q+j] == b[i][j] for j in range(m)) for i in range(m)):
            flag = True

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())
ans = True

for i in range(M):
    if B[i] not in A[i]:
        ans = False
        break

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

Solution (Python):
n, m = map(int, input().split())
ls0 = [input().rstrip() for _ in range(n)]
ls1 = [input().rstrip() for _ in range(m)]
ok = True
for i in range(n - m):
    for j in range(n - m):
        ok = True
        for k in range(m):
            for l in range(m):
                if ls0[i + k][j + l] != ls1[k][l]:
                    ok = False
                    break
            if not ok:
                break
        if ok:
            break
    if ok:
        break
if ok:
    print('Yes')
else:
    print('No')

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


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

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

ans = True
for k in range(len(B)):
    if B[k] not in A[k]:
        ans = False
        break
print("Yes" if ans == True else "No")

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

def match(ii,jj):
  res=1
  for i in range(M):
    if A[i+ii][jj:jj+M]!=B[i]:
      res=0
      break
  return res

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

print(ans)

Solution (Python):
def resolve():
    n, m = map(int, input().split())
    a = list(input() for _ in range(n))
    b = list(input() for _ in range(m))
    if n == m:
        if a == b:
            print('Yes')
        else:
            print('No')
        exit()
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            part = [ai[j:j + m] for ai in a[i:i + m]]
            if part == b:
                print("Yes")
                exit()
    print("No")


if __name__ == "__main__":
    resolve()

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

for i in range(N-M+1):
    for j in range(N-M+1):
        tmp = 1
        for l in range(M):
            for k in range(M):
                if A[i+l][j+k] != B[l][k]:
                    tmp = 0
        if tmp == 1:
            flag = 1
            
if flag == 1:
    print("Yes")
else:
    print("No")

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


for k in range(n-(m-1)):
	count=0
	for j in range(n):
		
		if l_n[j][k:k+m] == l_m[count]:
			count+=1
			if count==m:
				ans='Yes'
				break
		else:
			count=0
print(ans)

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

if N == M:
    if A == B:
        print('Yes')
    else:
        print('No')
    exit()

def isEmbeded(left, top):
    subA = [a[left: left + M] for a in A[top: top + M]]
    if subA == B:
        return True
    else:
        return False

for left in range(N - M):
    for top in range(N - M):
        if isEmbeded(left, top):
            print('Yes')
            exit()

print('No')

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

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

print("No")

Solution (Python):
import sys
def main():
    t = sys.stdin.readline()
    t1 = t.rstrip()
    t2 = t1.split(' ')
    stra = [] 
    for i in range(int(t2[0])):
        y = sys.stdin.readline()
        t = y.rstrip()
        stra += [t]
    strb = [] 
    for i in range(int(t2[1])):
        y = sys.stdin.readline()
        t = y.rstrip()
        strb += [t]
 
    suma = 0
    for x in strb:
        for y in stra:
            if x in y:
                suma +=1 
    if int(t2[0])*int(t2[1])==suma:
        print("Yes")
    else:
        print("No")
main()

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

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

    for i in range(N-M+1):
        for j in range(N-M+1):
            if cmp(A, B, i, j, N, M):
                print("Yes")
                return
    print("No")
    return

main()

Solution (Python):


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

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

    for i in range(N-M+1):
        for j in range(N-M+1):
            if cmp(i,j):
                print("Yes")
                return
    print("No")
    return

main()

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):
        flag = [False for _ in range(m)]
        for j in range(m):
            if a[y+j][x:m+x] == b[j]:
                flag[j] = True
        if all(flag):
            print("Yes")
            exit()
print("No")

Solution (Python):
import sys

def solve():
    n,m = map(int, sys.stdin.readline().split())
    A = [sys.stdin.readline().rstrip() for _ in range(n)]
    B = [sys.stdin.readline().rstrip() for _ in range(m)]
    for r in range(n-m+1):
        for c in range(n-m+1):
            X = []
            for i,a in enumerate(A[r:r+m]):
                if a[c:c+m] != B[i]:
                    break
            else:
                print('Yes')
                exit()
    print('No')

if __name__ == '__main__':
    solve()

Solution (Python):
def solve():
    n,m = map(int, input().split())
    A = [input() for _ in range(n)]
    B = [input() for _ in range(m)]
    for r in range(n-m+1):
        for c in range(n-m+1):
            X = []
            for i,a in enumerate(A[r:r+m]):
                if a[c:c+m] != B[i]:
                    break
            else:
                print('Yes')
                exit()
    print('No')

if __name__ == '__main__':
    solve()

Solution (Python):
def solve():
    n,m = map(int, input().split())
    A = [input() for _ in range(n)]
    B = [input() for _ in range(m)]
    for r in range(n-m+1):
        for c in range(n-m+1):
            X = []
            for i,a in enumerate(A[r:r+m]):
                if a[c:c+m] != B[i]:
                    break
            else:
                print('Yes')
                exit()
    print('No')

if __name__ == '__main__':
    solve()

Solution (Python):
import sys

def solve():
    n,m = map(int, sys.stdin.readline().split())
    A = [sys.stdin.readline().rstrip() for _ in range(n)]
    B = [sys.stdin.readline().rstrip() for _ in range(m)]
    for r in range(n-m+1):
        for c in range(n-m+1):
            X = []
            for a in A[r:r+m]:
                X.append(a[c:c+m])
            if X == B:
                print('Yes')
                exit()
    print('No')

if __name__ == '__main__':
    solve()

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

for r in range(n-m+1):
    for c in range(n-m+1):
        X = []
        for a in A[r:r+m]:
            X.append(a[c:c+m])
        if X == B:
            print('Yes')
            exit()
print('No')

Solution (Python):

def main():
    N, M, *AB = open(0).read().split()
    N, M = int(N), int(M)
    A, B, lim = AB[:N], AB[N:], N - M + 1
    for i in range(lim):
        for j in range(lim):
            if [A[j + k][i : i + M] for k in range(M)] == B:
                print("Yes")
                return
    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 ly in range(N):
    for lx in range(N):
        
        if ly+M-1 >= N or lx+M-1 >= N: continue

        
        match = True
        for y in range(M):
            for x in range(M):
                if A[ly+y][lx+x] != B[y][x]:
                    match = False
        if match:
            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)]

pt_max = m * m

def b():
    for i in range(n-m+1):
        for j in range(n-m+1):
            pt = 0
            for k in range(m):
                for l in range(m):
                    if A[i+k][j+l] == B[k][l]:
                        pt += 1
            if pt == pt_max:
                return "Yes"
    return "No"

print(b())

Solution (Python):
N, M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
flg = 0
for dx in range(N-M+1):
    for dy in range(N-M+1):


        if all(A[dy+i][dx:dx+M]==B[i] for i in range(M)):
            flg =1
if flg == 1: print("Yes")
else: print("No")

Solution (Python):
x,*c=open(0);n,m=map(int,x.split());o=n-m+1;print("YNeos"[all(any(c[p//o+q//m][p%o+q%m]!=c[n+q//m][q%m]for q in range(m*m))for p in range(o*o))::2])

Solution (Python):
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
for h in range(n-m+1):
	for w in range(n-m+1):
		if all(a[h+y][w+x]==b[y][x] for y in range(m) for x in range(m)):
			print("Yes")
			exit()
print("No")

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

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

    ok = False
    for sy in range(N-M+1):
        for sx in range(N-M+1):
            ok = True
            for y in range(M):
                for x in range(M):
                    if A[sy+y][sx+x] != B[y][x]:
                        ok = False
                        break
                if not ok:
                    break
            if ok:
                break
        if ok:
            break
    
    if ok:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Solution (Python):
import sys

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

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:j+M] == B[0]:
            check = True
            for k in range(1,M):
                if A[i+k][j:j+M] == B[k]:
                    pass
                else:
                    check = False
                    break
            if check:
                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)]


for i in range(N - M + 1):
    for j in range(N - M + 1):
        
        flag = True
        for x in range(M):
            for y in range(M):
                if A[i + x][j + y] != B[x][y]:
                    flag = False
                    break
            if flag == False:
                break
        if flag == True:
            print ('Yes')
            exit()

print ('No')

Solution (Python):
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]
for 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):
                if A[i+k][j+l]!=B[k][l]:
                    flg = False    
        if flg == True:
            print('Yes')
            exit()             
print('No')

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

for i in range(0,n-m+1):
    for j in range(0,n-m+1):
        if a[i][j:j+m] == b[0]:
            flag = 1
            for k in range(1,m):
                if a[i+k][j:j+m] != b[k]:
                    break
                flag += 1
            if flag == m:
                res = 'Yes'
        if res == 'Yes':
            break
    if res == 'Yes':
        break


print(res)

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

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

import sys

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

print("No")

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

for h in range(N-M+1):
  for w in range(N-M+1):
    for m in range(M):
      for mm in range(M):
        
        if Ngrid[h+m][w+mm] == Mgrid[m][mm]:
          continue
        else:
          break
      else:
        continue
      break
    else:
      print("Yes")
      exit()
else:
  print("No")

Solution (Python):
N,M=map(int,input().split());A=[input()for _ in range(N)];B=[input()for _ in range(M)];print("YNeos"[all(any(t!=s[j:j+M]for s,t in zip(A[i:],B))for i in range(N-M+1)for j in range(N-M+1))::2])

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




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

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





flag = False
for i in range(N - M + 1):
	for j in range(N - M + 1):
		
		
		
		lst = []
		for k in range(M):
			for l in range(M):
				lst.append(A[k + i][l + j])
		
		
		
		if ''.join(B) == ''.join(lst):
			flag = True
			
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)]

from itertools import permutations
import sys

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")
            sys.exit()

print("No")