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):
import sys
N,M=map(int,input().split())
A=[]
B=[]
A+=[str(input()) for i in range(N)]
B+=[str(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):
      for l in range(M):
        if B[k][l]!=A[i+k][j+l]:
          ans=0
    if ans:
      print("Yes")
      sys.exit()
print("No")

Solution (Python):
a = input().split()
n = int(a[0])
m = int(a[1])
img1 = []
for i in range(n):
    img1.append(input())
img2 = []
for j in range(m):
    img2.append(input())

def match(x, y):
    for k in range(m):
        for l in range(m):
            if img1[x+k][y+l] != img2[k][l]:
                return False
    return True

found = False
for i in range(n-m+1):
    for j in range(n-m+1):
        if match(i, j):
            found = True
if found:
    print("Yes")
else:
    print("No")

Solution (Python):
def contains(a, b):
  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:
        return True
  return False

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

imga = [raw_input() for i in range(N)]
imgb = [raw_input() for i in range(M)]
print 'Yes' if contains(imga, imgb) else 'No'

Solution (Python):
import sys
N, M = [int(i) for i in input().split()]

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

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

        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    diff = 1
                    break

            if diff == 1:
                break

        if diff == 0:
            print('Yes')
            sys.exit()

print('No')

Solution (Python):
N, M = map(int, raw_input().split())
A = [raw_input() for i in range(N)]
B = [raw_input() for i in range(M)]
def judge():
    for i in range(N-M+1):
        for j in range(N-M+1):
            ok = True
            for r in range(M):
                for c in range(M):
                    if A[i+r][j+c] != B[r][c]:
                        ok = False
            if ok:
                return "Yes"
    return "No"
print judge()

Solution (Python):

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

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

print('No')

Solution (Python):
def bsolve(a,b,c,d):
	M=len(b)
	for i in range(M):
		for j in range(M):
			if(a[c+i][d+j]!=b[i][j]):
				return 0
	return 1
def b():
	N,M=list(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):
			if(A[i][j]==B[0][0]):
				flag=bsolve(A,B,i,j)
				if(flag==1):
					print("Yes")
					return 
	if(flag==1):
		print("Yes")
	else:
		print("No")
b()

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

a = []
b = []

for _ in range(n):
  a.append(list(input()))

for _ in range(m):
  b.append(list(input()))

for i in range(n-m+1):
  for j in range(n-m+1):
   flag = True
   for k in range(m):
     for l in range(m):
       if(a[i+k][j+l] != b[k][l]):
         flag = False
         break
     if(flag == False):
       break

   if(flag == True):
     print("Yes")
     exit()


print("No")

Solution (Python):
so, sp = list(map(int, input().split()))
orig = []
part = []
for i in range(so):
    orig.append(input())
for i in range(sp):
    part.append(input())
sd = so - sp
def check(orig, part, sd, sp):
    for x in range(sd+1):
        for y in range(sd+1):
            if [a[y:y+sp] for a in orig[x:x+sp]] == part:
                return True
    return False
print('Yes' if check(orig, part, sd, sp) else 'No')

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

agree = False
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:
            agree = True
            break
    if agree:
        break
if agree:
    print("Yes")
else:
    print("No")

Solution (Python):


import sys
import os


N, M = map(int, input().split())
if N < M:
    print('No')
    quit()

A = []
for i in range(N):
    lst = list(input().strip())
    A.append(lst)

B = []
for i in range(M):
    lst = list(input().strip())
    B.append(lst)





for offset_i in range(N-M+1):
    for offset_j in range(N-M+1):
        
        all_match = True
        for i in range(M):
            for j in range(M):
                if A[i+offset_i][j+offset_j] != B[i][j]:
                    all_match = False
        if all_match:
            print('Yes')
            quit()
print('No')

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

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

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

Solution (Python):
n,m = map(int, raw_input().split())
picA = [raw_input() for _ in range(n)]
picB = [raw_input() for _ in range(m)]
find = True
for x in range(n-m+1):
    for y in range(n-m+1):
        find = True
        for p in range(m):
            if picA[y+p][x:x+m] != picB[p]:
                find = False
                break
        if find:
            break
    if find:
        break
if find:
    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())
t = 0
for i in range(N-M+1):
	for j in range(N-M+1):
		t = 0
		for k in range(M):
			if t:
				break
			for l in range(M):
				if A[i+k][j+l] != B[k][l]:
					t = 1
					break
		else:
			if A[i+k][j+l] == B[k][l]:
				print("Yes")
				exit()
print("No")

Solution (Python):
def main():
    
    
    n, m = [int(x) for x in input().split()]
    a = []
    b = []
    for _ in range(n):
        
        a.append(input())
    for _ in range(m):
        
        b.append(input())
    if solve(a, b, n, m):
        print("Yes")
    else:
        print("No")


def solve(a, b, n, m):
    for row in range(n - m + 1):
        for col in range(n - m + 1):
            if check(a, row, col, b, m):
                return True
    return False


def check(a, row, col, b, m):
    for this_row in range(row, row + m):
        for this_col in range(col, col + m):
            if a[this_row][this_col] != b[this_row - row][this_col - col]:
                return False
    return True


if __name__ == "__main__":
    main()

Solution (Python):
def check_match(A, B):
    N = len(A)
    M = len(B)
    for i in range(N):
        for j in range(N):
            match = True
            for k1 in range(M):
                for k2 in range(M):
                    if i+k1 >= N or j+k2 >= N or A[i+k1][j+k2] != B[k1][k2]:
                        match = False
                        break
            if match == True:
                return True
    return False

if __name__ == "__main__":
    size = [int(i) for i in input().split()]
    N = size[0]
    M = size[1]
    A = []
    B = []
    for i in range(N):
        A.append(input())
    for i in range(M):
        B.append(input())
    if check_match(A, B) == True:
        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)]

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

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

Solution (Python):
size = list(map(int,raw_input().split()))

large_pic=[]
small_pic=[]
for i in range (size[0]):
    large_pic.append (list(raw_input().strip()))
for i in range (size[1]):
    small_pic.append (list(raw_input().strip()))


flag = False
cut_pic = []
for i in range (size[0]-size[1]+1):
    for j in range (size[0]-size[1]+1):
        for k in range (size[1]):
            cut_pic.append(large_pic[i+k][j:j+size[1]])
        if cut_pic == small_pic:
            flag = True
        else:
            cut_pic =[]
print "Yes" if flag == True else "No"

Solution (Python):

import numpy as np

N,M = map(int, raw_input().split())
image = np.zeros((N,N),dtype='int8')
template = np.zeros((M,M),dtype='int8')
YesFlag = 0

for i in range(N):
    S = raw_input()
    for j in range(len(S)):
        if(S[j]=='
            image[i][j] = 0
        elif(S[j]=='.'):
            image[i][j] = 1
for i in range(M):
    S = raw_input()
    for j in range(len(S)):
        if(S[j]=='
            template[i][j] = 0
        elif(S[j]=='.'):
            template[i][j] = 1




for i in range(N-M+1):
    for j in range(N-M+1):
        
        if(np.all(image[i:M+i,j:M+j]==template) == True):
            YesFlag = 1
            break
    if(YesFlag == 1):
        break

if(YesFlag == 1):
    print('Yes')
else:
    print('No')

Solution (Python):

import sys
import math
import numpy as np


def main():
    
    
    N, M = map(int, input().split())
    sA = ''.join([input() for i in range(N)])
    sB = ''.join([input() for i in range(M)])
    A = np.array([s for s in sA]).reshape(N,N)
    B = np.array([s for s in sB]).reshape(M,M)

    
    result = np.zeros((N-M+1,N-M+1), dtype=bool)
    for i in range(N-M+1):
        for j in range(N-M+1):
            result[i,j] = (A[i:i+M, j:j+M] == B).all()

    
    if result.any():
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N, M = map(int, input().split())
    A = []
    for i in range(N):
        A.append(input())
    B = []
    for i in range(M):
        B.append(input())
    for i in range(N - M + 1):
        for j in range(N - M + 1):
            if check(i, j, M, A, B):
                print('Yes')
                return
    print('No')


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

if __name__ == '__main__':
    main()

Solution (Python):

if __name__ == '__main__':
  s = str(input()).split(" ")
  N = int(s[0])
  M = int(s[1])
  A, T = list(), list()
  for i in range(0,N):
    A.append(input())
  for i in range(0,M):
    T.append(input())

  
  
  
  
  ans = False
  for t in range(0, N-M+1):
    for l in range(0, N-M+1):
      ok = True
      for i in range(t, t+M):
        for j in range(l, l+M):
          if A[i][j] != T[i-t][j-l]:
            ok = False
      if ok:
        ans = True
  if ans:
    print("Yes")
  else:
    print("No")

Solution (Python):
import sys

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

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

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

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if k <= m-2:
                if a[i+k][j:j+m] == b[k]:
                    continue
                else:
                    break
            else:
                if a[i+k][j:j+m] == b[k]:
                    print("Yes")
                    sys.exit()
                else:
                    break

print("No")

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

for i in range(m-n+1):
    for j in range(m-n+1):
        frag = 0
        for a in range(n):
            for b in range(n):
                if mlist[i+a][j+b] != nlist[a][b]:
                    frag = 1
            if frag == 1:
                break
        if frag == 0:
            print("Yes")
            sys.exit()
print("No")

Solution (Python):
def main():
    nm = map(int, raw_input().split())
    A = []
    B = []
    flag = False
    for i in range(nm[0]):
        A.append(raw_input())
    for i in range(nm[1]):
        B.append(raw_input())

    for i in range(nm[0]):
      if i + nm[1] <= nm[0]:
        for j in range(nm[0]):
            if j + nm[1] <= nm[0]:
                for k in range(nm[1]):
                    for l in range(nm[1]):
                        if(A[i+k][j+l] == B[k][l]):
                            flag = True
                        else:
                            flag = False
                            break 
                    if flag == False:
                        break
            else:
                break
            if flag:
                 break
        if flag:
            break
      else:
          break
       
    if flag:
        return "Yes"
    else:
        return "No"    
print main()

Solution (Python):
import numpy as np

N, M = [int(x) for x in input().split()]
A=[]
B=[]
for i in range(N):
    A.append(list(input()))
for j in range(M):
    B.append(list(input()))
A = np.array(A)
B = np.array(B)
for i in range(N-M+1):
    for j in range(N-M+1):
        A_ = A[i:(i+M),j:(j+M)]
        if np.array_equal(A_,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)]
 
ans = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        t = [k[j:j+M] for k in a[i:i+M]]
        if t==b: ans =1
 
print("Yes" if ans else "No")

Solution (Python):
t = list(str(input()).split(" "))
n = int(t[0])
m = int(t[1])

a = list()
for i in range(n):
    a.append(str(input()))

b = list()
for i in range(m):
    b.append(str(input()))

c = n-m+1
for i in range(c):
    for j in range(c):
        fg = False
        for k in range(m):
            if(fg == True):break
            for l in range(m):
                if(fg == True):break
                if(a[i+k][j+l] != b[k][l]):
                    fg = True
                    break

        if(fg == False):
            print("Yes")
            exit()

print("No")

Solution (Python):
def subImage(x,y,M,A):
    C = []
    for i in range(M):
        C.append(A[x+i][y:y+M])
    return C
    
def containIm(N,M,A,B):
    judge = 0    
    for x in range(N-M+1):
        for y in range(N-M+1):
            C = subImage(x,y,M,A)
            if C == B:
                judge = 1
                return judge
    return judge
    


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

judge = containIm(N,M,A,B)
if judge == 1:
    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)]

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

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

Solution (Python):



def matching(x,y):
    for s in range(m):
        for t in range(m):
            if not a[x+s][y+t] == b[s][t]:
                return 0

    return 1


if __name__ == '__main__':
    
    n, m = map(int,raw_input().split())
    a=[]
    for i in range(n):
        a.append(list(raw_input()))
    b=[]
    for j in range(m):
        b.append(list(raw_input()))


    
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            
            ans = matching(i,j)
            if ans == 1:
                print 'Yes'
                exit()

    if ans == 0:
        print 'No'

    '''
    基準点をスライドさせていく
    一列目がマッチングするか確認
    その後の列もマッチングするか確認
    全てマッチすればYesと返す
    '''

Solution (Python):
n,m = map(int, raw_input().split())
np=[]
mp=[]
for i in xrange(0, n):
  np.append(raw_input())
for i in xrange(0, m):
  mp.append(raw_input())
 
for i in xrange(0,n-m+1):
  for j in xrange(0, n-m+1):
    flag = True
    for x in xrange(0, m):
      for y in xrange(0, m):
        if mp[x][y] != np[i+x][j+y]:
          flag = False
          break
      if flag == False:
        break
    if flag:
      print "Yes"
      break
  if flag: break
if flag==False: print "No"

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

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

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

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

for _ in xrange(N):
    A.append(raw_input())
for _ in xrange(M):
    B.append(raw_input())

def match(x, y):
    for i in xrange(M):
        for j in xrange(M):
            if A[x+i][y+j] != B[i][j]: return None
    return 1

def main():
    for x in xrange(N-M+1):
        for y in xrange(N-M+1):
            if match(x, y):
                return 'Yes'
    return 'No'

if __name__ == '__main__':
    print main()

Solution (Python):
n, m = map(int, raw_input().strip().split(" "))
arr_n = [None] * n
arr_m = [None] * m
for i in range(n):
	arr_n[i] = raw_input().strip()
for i in range(m):
	arr_m[i] = raw_input().strip()

found = False
for i in range(n-m+1):
	if found:
		break
	for j in range(n-m+1):
		if found:
			break
		match = True
		for k in range(m):
			if arr_m[k] != arr_n[i+k][j:j+m]:
				match = False
				break
		if match:
			found = True
			print "Yes"
if not found:
	print "No"

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

for p in range(n-m+1):
    for q in range(n-m+1):
        ans=0
        for i in range(m):

            row = str(a[q+i])
            cut = str(row[p:p+m])

            if cut == b[i]:
                ans += 1
                
            

        if ans == m:
            print('Yes')
            exit()

print('No')

Solution (Python):




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

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

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

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

def move(d):
	for x in range(d):
		for y in range(d):
			if check(x, y):
				return True
	return False

is_include = move(n-m+1)

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

ret = False
for i in range(N):
    for j in range(N):
        if i + M > N or j + M > N:
            continue
        f = True
        for k in range(M):
            for l in range(M):
                if A[i + k][j + l] != B[k][l]:
                    f = False
                    break
            if not f:
                break
        if f:
            ret = True
if ret:
    print('Yes')
else:
    print("No")

Solution (Python):
import numpy as np

n, m = [int(i) for i in input().split()]

N, M = [], []
for i in range(n):
    N.append(list(input()))
for i in range(m):
    M.append(list(input()))

N, M = np.array(N), np.array(M)




def match():
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            
            if (N[i:i+m, j:j+m] == M).all():
                return "Yes"
    return "No"

print(match())

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

N, M = [], []
for i in range(n):
    N.append(list(input()))
for i in range(m):
    M.append(list(input()))




def check():
    for i in range(n-m+1):
        for j in range(n-m+1):
            flag = True
            for ii in range(m):
                for jj in range(m):
                    flag &= N[i+ii][j+jj] == M[ii][jj]
                    if not flag: break
                if not flag: break
            if flag: return "Yes"
    return "No"

print(check())

Solution (Python):

A = []
B = []
N, M = list(map(int, input().split()))

for n in range(N):
    A.append(input())
for n in range(M):
    B.append(input())

def match(r, c):
    for i, row in enumerate(range(r, r+M)):

        if A[row][c:c+M] != B[i]:
            return False
    return True

ok = 0

for r in range(N-M+1):
    if ok == 1:
        break
    else:
        for c in range(N-M+1):
            if match(r, c):
                print("Yes")
                ok = 1
                break
            
if not ok:
    print("No")

Solution (Python):
import itertools

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

ref_tuple = itertools.product(range(0,N-M+1),range(0,N-M+1))
t=False
for ref_row_a, ref_col_a in ref_tuple:
    for row_b, col_b in itertools.product(range(0,M),range(0,M)):
        if not A[ref_row_a+row_b][ref_col_a+col_b]==B[row_b][col_b]:
            break
        if (row_b, col_b)==(M-1,M-1):
            t=True
            break
    if t:
        break

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

Solution (Python):
n,m = map(int, raw_input().split())
aa = [0] * n
bb = [0] * m
for i in range(n):
    aa[i] = list(raw_input())
for i in range(m):
    bb[i] = list(raw_input())

flag = True
for i in range(n-m):
    for j in range(n-m):
        flag = True
        for ik in range(m):
            for jk in range(m):
                if aa[i+ik][j+jk] != bb[ik][jk]:
                    flag = False
                    
        if flag == True: break
    if flag == True: break

if flag == True:
    print 'Yes'
else:
    print 'No'

Solution (Python):


N,M = [int(x) for x in raw_input().split(' ')]

A = [raw_input() for x in range(N)]
B = [raw_input() for x in range(M)]

def getpattern(image, s = 0, x = 0, y = 0):
    if s == 0:
        s = len(image)

    return ''.join([image[i][x:x+s] for i in range(y, y + s)])

def match(N,M,A,B):
    size = M

    bpattern = getpattern(B)
    for j in range(0, N - M + 1):
        for i in range(0, N - M + 1):
            if getpattern(A, size, i, j) == bpattern:
                return 'Yes'

    return 'No'

print match(N,M,A,B)

Solution (Python):
def srch_all(ptn, str):
    index = []
    i = -1
    while True:
        i = str.find(ptn, i + 1)
        if i > -1:
            index.append(i)
        else:
            break
    return index

def judge(i, jlist, len):
    for l in jlist:
        k = 1
        while k < M:
            try:
                if n[i + 1][l:l + len] == m[k]:
                    pass
                else:
                    return 'No'
            except:
                return 'No'
            i += 1
            k += 1
        else:
            return 'Yes'

N, M = map(int, input().split())
i = 0
n = []
while i < N:
    n.append(input())
    i += 1

i = 0
m = []
while i < M:
    m.append(input())
    i += 1

i = 0
r = 'No'
while i < N:
    result = srch_all(m[0], n[i])
    if len(result) > 0:
        r = judge(i, result, len(m[0]))
        if r == 'Yes':
            break
    i += 1
print(r)

Solution (Python):
import sys

A=[]
B=[]
NM=input().split(" ")
N=int(NM[0])
M=int(NM[1])

for i in range(N):
    t=input()
    A.append(t)
for i in range(M):
    t=input()
    B.append(t)



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


def f():
    if a == b:
        return True
    for i in range(n - m):
        for j in range(n - m):
            for k in range(m):
                if a[i + k][j:j + m] != b[k]:
                    break
            else:
                return True
    return False

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

Solution (Python):

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


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


a = []
for i in range(n):
	a.append(list(raw_input()))


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


found = False
for i in range(n-m+1):
	for j in range(n-m+1):
		if findMatch(i,j):
			found = True

if found:
	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())
for y in range(n-m+1):
    for x in range(n-m+1):
        eq=True
        for yy in range(m):
            for xx in range(m):
                eq &= a[y+yy][x+xx] == b[yy][xx]
                if not eq: break
            if not eq: break
        if eq:
            print("Yes")
            exit(0)
print("No")

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






L = N-M

def check(i,j):
    ans=True
    for line in range(M):
        if (ans==False):
            break
        for row in range(M):
            if (a[i+line][j+row]!=b[line][row]):
                ans=False
                break
    return ans

ans=False
for i in range(L+1):
    if(ans==True):
        break
    for j in range(L+1):
        ansnow=check(i,j)
 
        if(ansnow==True):
            ans=True
            break
if(ans==True):
    print('Yes')
else:
    print('No')

Solution (Python):
from itertools import product as prd

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


c = n - m + 1
ans = [list(map(lambda l: l[j:j+m], a[i:i+m])) == b for i, j in prd(range(c), range(c))]
print("Yes" if any(ans) else "No")

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

res = "No"
c = n - m + 1
for i in range(c):
    for j in range(c):
        if list(map(lambda l: l[j:j+m], a[i:i+m])) == b:
            res = "Yes"
print(res)

Solution (Python):

import sys
N,M=map(int,input().split())
Alist=[input() for i in range(0,N)]
Blist=[input() for i in range(0,M)]

def is_match(A,B,M):
    for i in range(0,M):
        if A[i]!=B[i]:
            return False
    return True

def make_A(A,i,j,M):
    C=[0]*M
    for k in range(0,M):
        C[k]=A[k+i][j:j+M]
    return C

for i in range(0,N-M+1):
    for j in range(0,N-M+1):
        C=make_A(Alist,i,j,M)
        if is_match(C,Blist,M):
            print("Yes")
            sys.exit()
print("No")

Solution (Python):
from collections import defaultdict


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

    for sy in range(N):
        for sx in range(N):

            ok = True
            for y in range(M):
                for x in range(M):
                    if sy + y < N and sx + x < N:
                        ok &= A[sy + y][sx + x] == B[y][x]
                    else:
                        ok = False

            if ok:
                print("Yes")
                return
    print("No")


if __name__ == '__main__':
    main()

Solution (Python):

import sys

n,m=map(int,raw_input().split())
a=[]
b=[]
for i in xrange(n):
 a.append(raw_input())
for i in xrange(m):
 b.append(raw_input())
for i in xrange(m):
 if b[i] not in a[i]:
  print 'No'
  sys.exit()
 else:
  print 'Yes'
  sys.exit()

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

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

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n,m = LI()
    a = []
    for i in range(n):
        t = 0
        for c in S():
            t <<= 1
            if c == '
                t += 1
        a.append(t)

    b = []
    for i in range(m):
        t = 0
        for c in S():
            t <<= 1
            if c == '
                t += 1
        b.append(t)

    mask = 2**m-1
    for i in range(n-m+1):
        for j in range(n-m+1):
            f = True
            for k in range(m):
                ak = (a[k+j] >> i) & mask
                if ak != b[k]:
                    f = False
                    break
            if f:
                return 'Yes'
    return 'No'


print(main())

Solution (Python):

import sys
import io

sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

n, m = map(int, input().split())
n_list = [input().split()[0] for _ in range(n)]
m_list = [input().split()[0] for _ in range(m)]
dif = n-m

ans = ""

class DropNest(Exception):
    pass 

try:
    for i in range(dif+1):
        for j in range(dif+1):
            target = n_list[i][j:j+m]
           
            if target != m_list[0]:
                continue
            else:
                cnt = 0
                for k in range(m):
                    target_h = n_list[i+k][j:j+m]
                    if target_h == m_list[k]:
                        cnt+=1
                if cnt==m:
                    ans="Yes"
                    raise DropNest
    print("No")
except DropNest:
    print(ans)

Solution (Python):


if __name__ == '__main__':
    n, m = [int(s) for s in raw_input().split()]
    a = [raw_input().strip() for row in range(n)]
    b = [raw_input().strip() for row in range(m)]

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