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):
s = input()
l = s.split()
N = int(l[0])
M = int(l[1])

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

B = list()
for j in range(M):
    s = input()
    B.append(s)


def g(n, m, a, b, i, j):
    for k in range(m):
        for l in range(m):
            if a[i + k][j + l] != b[k][l]:
                return False
    return True


def f(N, M, A, B):
    for i in range(N - M + 1):
        for j in range(N - M + 1):
            if g(N, M, A, B, i, j):
                return 'Yes'
    return 'No'

print(f(N, M, A, B))

Solution (Python):
m, n = input().split()
m = int(m)
n = int(n)
a = []
for i in range(m):
  row = input().rstrip()
  x = 0
  for c in row:
    x *= 2
    if c == "
      x += 1
  a.append(x)

b = []
for i in range(n):
  row = input().rstrip()
  x = 0
  for c in row:
    x *= 2
    if c == "
      x += 1
  b.append(x)
c = 2 ** n
found = False
for i in range(m - n + 1):
  for j in range(m - n + 1):
    if found:
      break
    found = True
    for k in range(n):
      if (((a[i+k] >> (m - n - j)) ^ b[k]) % c) != 0:
        found = False
        break
if found:
  print("Yes")
else:
  print("No")

Solution (Python):

import re
import sys
N, M = map(int,input().split())
A = [ input() for i in range(N) ] 
B = [ input() for i in range(M) ]
for tmp in range(N-M+1):
    for tmp2 in range(N-M+1):
        flag = True
        for tmp3 in range(M):
            for tmp4 in range(M):
                if A[tmp+tmp3][tmp2+tmp4] != B[tmp3][tmp4]:
                    flag = False
        if flag:
            print("Yes")
            sys.exit()
print("No")

Solution (Python):
N, M = map(int, input().split())
A = [input() for x in range(N)]
B = [input() for x in range(M)]
c = []
for i in range(N-M+1):
    for j in range(N-M+1):
        a = []
        for y in range(M):
            a += [A[j+y][i:i+M]]
        c += [a]
print('Yes' if sum(1 for x in c if x == B)>0 else 'No')

Solution (Python):
m,n=map(int,raw_input().split())
a=[]*m
b=[]*n
p=0
q=0
while(q<m):
	q+=1
	a.append(raw_input())
while(p<n):
	p+=1
	b.append(raw_input())
flag=False


for i in xrange(n):
	if not b[i] in (a[i]):
		flag=True
		break
if flag:
	print "No"
else:
	print "Yes"

Solution (Python):
import sys
if __name__ == '__main__':

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

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

    char = B[0][0]
    matc = False
    for i in range(N-M+1):
        for j in range(N-M+1):
            if A[i][j] == char:
                matc = True
                for k in range(M):
                    for l in range(M):
                        if A[i+k][j+l] == B[k][l]:
                            matc = True
                        else:
                            matc = False
                            break
                    if not matc:
                        break
                if matc == True:
                    print("Yes")
                    sys.exit(0)

    if matc == True:
        print("Yes")
    else:
        print("No")

Solution (Python):
import sys

count = 0
N_list = []
M_list = []
for line in sys.stdin:
    line = line.rstrip("\n")
    if count == 0:
        line = line.split(" ")
        N = int(line[0])
        M = int(line[1])
    elif count <= N:
        N_list.append(line)
    else:
        M_list.append(line)
    count+=1
    
    
def judge_match(N_l, M_l):
    slide_count = len(N_l[0]) - len(M_l[0]) + 1
    count = 0
    for j in range(slide_count):
        count = 0
        for i in range(len(N_l)):
            if N_l[i][j:j+len(M_l[0])] == M_l[i]:
                count += 1
                if count == len(M_l):
                    return count
    return count

m_count = 0
for i in range(len(N_list)):
    m_count = judge_match(N_list[i:i+len(M_list)], M_list)
    if m_count == len(M_list):
        print("Yes")
        exit(0)
print("No")

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

AB = [input() for i in range(0, N + M)]
A = AB[0: N]
B = AB[N:]

diff = N - M
matches = []
for i in range(0, diff+1):
    l = 0
    while N - l > diff:
        index = A[i][l:].find(B[0])
        if index != -1 and i <= diff:
            matches.append((index, l, i))
        l += 1
if len(matches) == 0:
    print("No")
    sys.exit()
count_no = []
for m, l, i in matches:
    for a, b in zip(A[i:], B):
        if a[l:].find(b) != m:
            count_no.append(0)
            break
if len(count_no) == len(matches):
    print("No")
else:
    print("Yes")

Solution (Python):

n, m = map(int, raw_input().split())
a = [raw_input() for _ in xrange(n)]
b = [raw_input() for _ in xrange(m)]
f = 0
for i in xrange(m):
    if b[i] in a[i]:
        f += 1

if f == m:
    print "Yes"
else:
    print "No"

Solution (Python):
n,m = map(int,input().strip().split())
ns,ms = [],[]
for _ in range(n):
    ns.append(input().strip())
for _ in range(m):
    ms.append(input().strip())

allFlag = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        if ns[i][j:j+m] == ms[0]:
            Flag = 1
            for k in range(m):
                if ns[i+k][j:j+m]!=ms[k]:
                    Flag = 0
            if Flag and not allFlag:
                print("Yes")
                allFlag = 1
if not allFlag:
    print("No")

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

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

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


def check_photo(base, target):
    for i in range(n-m+1):
        check = base[i:i+m]

        for j in range(n-m+1):
            check2 = [line[j:j+m] for line in check]

            if check2 == target:
                return print('Yes')
    return print('No')

check_photo(a, b)

Solution (Python):
def compare_image(A, B, N, M):
    for i in range(N):
        for j in range(N):
            
            if (i+M <= N) and (j+M <= N):
                b_flag = True

                for k in range(M):
                    str_a = A[i+k][j:j+M]
                    str_b = B[k]
                    if str_a != str_b:
                        b_flag = False

                if b_flag:
                    return True

    return False


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

if compare_image(A, B, N, M):
    string = "Yes"
else:
    string = "No"

print(string)

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

f = [0]*m
tmp = []
for j in range(m):
    f[j] = a[j].find(b[j])
    if f[j] != -1:
        tmp.append(j)
while -1 in f: f.remove(-1)

try:
    if len(f) == 0:
        print('No')
    else:
        count = 0
        for i in range(len(tmp)):
            count += 1
            if (b[tmp[i]] in a[tmp[i]]) == False:
                count = 0
        if count == m:
            print('Yes')
        else:
            print('No')
except:
    print('No')

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

res=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 res else '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):
        if a[i][j] == b[0][0]:
            c = []
            for k in range(m):
                c.append(a[i + k][j:j + 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)]
f = 0
for i in range(N-M+1):
	for j in range(N-M+1):
		for k in range(M):
			if f:
				f = 0
				break
			for l in range(M):
				if A[i+k][j+l] != B[k][l]:
					f = 1
					break
			else:
				if k == l == M-1:
					print("Yes")
					exit()
print("No")

Solution (Python):
import sys

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

strNs = []
strMs = []

for n in range(N):
	strNs.append(input())
	
for m in range(M):
	strMs.append(input())
	
def check_rest(start_row, start_col):
	for j in range(1,M):
		if strNs[start_row+j][start_col:start_col+M] != strMs[j]:
			return False
	else:
		return True
		

for i in range(N-M+1):
	tmp = strNs[i].find(strMs[0])
	while tmp >= 0:
		if check_rest(i, tmp):
			print("Yes")
			sys.exit()
		elif tmp + M > N:
			break
		else:
			tmp = strNs[i].find(strMs[0],tmp+1)
			
print("No")

Solution (Python):
def equal(A,B,i,j):
	ret = True
	for row in xrange(i,i+len(B)):
		if A[row][j:j+len(B)] != B[row-i]:
			ret = False
	return ret

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


contained = False
for i in xrange(n-m+1):
	for j in xrange(n-m+1):
		if equal(A,B,i,j):
			contained = True
			break
		else:
		 	pass
	if contained: break

if contained: print 'Yes'
else: print 'No'

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

for i in range(N-M+1):
    index=A[i].find(B[0])
    if index==-1:
        continue
    for j in range(M):
        if A[i+j][index:index+M] !=B[j]:
            break
    else :
        print "Yes"
        break
else:
    print "No"

Solution (Python):
import itertools

def solve(n, m, a, b):
    for i, j in itertools.product(range(n - m + 1), repeat=2):
        if all(a[i + x][j + y] == b[x][y] for x, y in itertools.product(range(m), repeat=2)): return "Yes"
    return "No"


if __name__ == '__main__':
    n, m = map(int, input().split())
    a = [[token for token in input()] for _ in range(n)]
    b = [[token for token in input()] for _ in range(m)]

    ans = solve(n, m, a, b)
    print(ans)

Solution (Python):

n = input().split()

ar = int(n[0])
br = int(n[1])

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

for j in range(0, br):
    b.append(input())

find = False
for i in range(0, ar - br + 1):
    for j in range(0, ar -br + 1):
        if a[i][j] == b[0][0]:
            same = True
            for k in range(0, br):
                for l in range(0, br):
                    if a[i+k][j+l] != b[k][l]:
                        same = False
                        break
            if same:
                find = True
                break
if find:
    print("Yes")
else:
    print("No")

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

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

check = True
Flag = False

for s in range(N-M+1):
    for t in range(N-M+1):
        check = True
        for p in range(M):
            for q in range(M):
                if A[s+p][t+q] != B[p][q]:
                    check = False
        if check:
            Flag = True

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

Solution (Python):
import numpy as np
import sys

if __name__=="__main__":
   N, M = list(map(int, input().replace("\n","").split(" ")))
   a = [list(map(int, list(input().replace("\n","").replace(".", "1").replace("
   a = np.array(a)
   b = [list(map(int, list(input().replace("\n","").replace(".", "1").replace("
   b = np.array(b)


   for i in range(N - M + 1):
       for j in	range(N - M + 1):
           if((a[i:i+M,j:j+M] == b).all()):
               print("Yes")
               sys.exit(0)
   print("No")

Solution (Python):
nums = list(map(int, input().split()))
N =  nums[0] 
M = nums[1] 
K = N - M + 1
a = 0
b = 0
m = [[]]
n  = [[]]
while(a<N):
	if a == 0:
		n[0] = list(input())
	else:
		n.append(list(input()))
	a+=1
while(b<M):
	if b == 0:
		m[0] = list(input())
	else:
		m.append(list(input()))
	b+=1
judge = 0
for i in range(K):
	for j in range(K):
		num = 0
		for h in range(M):
			for k in range(M):
				if(m[h][k] == n[h+i][k+j]):
					num+=1
		if num == M*M:
			judge = 1

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

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


def is_ok(A, B):
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            C = []
            for k in range(i, i + m):
                line = ""
                for l in range(j, j + m):
                    line += A[k][l]
                C.append(line)
            
            if C == B: return True
    return False


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

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


if is_ok(A, B):
    print("Yes")
else:
    print("No")

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

A=[]
B=[]
for i in xrange(N):
    A.append(list(raw_input()))


for i in xrange(M):
    B.append(list(raw_input()))


diff=N-M+1


found=False
for i in xrange(diff):
    for j in xrange(diff):
        wrong=False
        for k1 in xrange(M):
            for k2 in xrange(M):
                if A[i+k1][j+k2] != B[k1][k2]:
                    wrong=True
                    break
            if wrong:
                break
        if wrong==False:
            found=True
            break
    if found==True:
        break
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())

def is_contain(i, b_pos):
    containing = True
    for k in range(1, m):
        if A[i+k][b_pos:(b_pos+len(B))] != B[k]:
            containing = False
    return containing

if n < m or len(A) < len(B):
    print("No")
    exit()

for i in range(n - m + 1):
    lineA = A[i]
    lineB = B[0]
    lineB_pos = lineA.find(lineB)
    if lineB_pos >= 0:
        if is_contain(i, lineB_pos):
            print("Yes")
            exit()

print("No")

Solution (Python):
data = raw_input()

n,m = map(int,data.split(" "))

data = []

for x in range(n):
  data.append(raw_input())

temp = []

for x in range(m):
  temp.append(raw_input())

for x in range(n-m+1):
  for y in range(n-m+1):
    if temp[0] == data[x][y:y+m]:
      flag = 1
      pos = y
      for xx in range(x+1,x+m):
        if temp[xx - x] != data[xx][pos:pos+m]:
          flag = 0
          break
      if flag == 1:
        print "Yes"
        exit(0)

print "No"

Solution (Python):
from itertools import product

n, m = [int(i) for i in input().rstrip().split()]
AA = [[0 if i == '.' else 1 for i in input().rstrip()] for _ in range(n)]
BB = [[0 if i == '.' else 1 for i in input().rstrip()] for _ in range(m)]

for i_r, i_c in product(range(n - m + 1), range(n - m + 1)):
    i_r -= 1
    i_c -= 1
    for k_r, k_c in product(range(m), range(m)):
        if AA[i_r + k_r][i_c + k_c] == BB[k_r][k_c]:
            continue
        else:
            break
    else:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
import sys
import numpy as np

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

A = np.array(A)
B = np.array(B).flatten()

for row in range(N - M + 1):
    for col in range(N - M + 1):
        patch = A[row:row + M, col:col + M].flatten()
        if str(patch) == str(B):
            print('Yes')
            sys.exit()
print('No')

Solution (Python):
import numpy as np
import sys
temp = input().split()
N = int(temp[0])
M = int(temp[1])
A = []
B = []
check = False
def change(n):
  if(n=='
    return True;
  return False;

for i in range(N):
  temp = input()
  A.append(list(map(change, temp)))
for i in range(M):
  temp = input()
  B.append(list(map(change, temp)))
A = np.array(A)
B = np.array(B)

for i in range(N-M+1):
  for j in range(N-M+1):
    if (B== A[i:M+i, j:M+j]).all():
      check = True
      break
  if check:
    break

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

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

found = False
for x in range(m-n+1):
  for y in range(m-n+1):
    for k in range(n):
      if a[x+k][y:y+n] != b[k]:
        break
    else:
      found = True
      break
  if found: break    
if found:
  print("Yes")
else:
  print("No")

Solution (Python):
n,m=map(int,input().split())
master,sub=[],[]
for i in range(n):
    master.append(input())
for j in range(m):
    sub.append(input())
def chk(a,b,y,x):
    t=len(b)
    for i in range(t):
        if a[y+i][x:x+t]!=b[i]:
            return 0
    return 1

for i in range(n-m+1):
    for j in range(n-m+1):
        if master[i][j:j+m]==sub[0]:
            if chk(master,sub,i,j):
                print('Yes')
                exit()
print('No')

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


def check(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 check(i, j):
            print "Yes"
            exit()
print "No"

Solution (Python):
import numpy as np
N, M = map(int,input().split())
A = [list(map(lambda x: 1 if x == "." else 0, list(input()))) for n in range(N)]
B = [list(map(lambda x: 1 if x == "." else 0, list(input()))) for m in range(M)]

A = np.array(A)
B = np.array(B)

flag = False
for r in range(N-M+1):
    for c in range(N-M+1):
        if (A[r:r+M, c:c+M] == B).all():
            flag = True
if flag:
    print("Yes")
else:
    print("No")

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

N, M = map(int, raw_input().split())
A, B = [], []
for i in range(N): A.append(raw_input())
for i in range(M): B.append(raw_input())
result = "No"
for x in range(N):
	for y in range(N):
		if(match_m(x,y,N,M,A,B)): 
			result = "Yes"
			break
print result

Solution (Python):
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

(N, M) = reads()

A = []; B = []
for _ in range(N):
  s = input()
  A.append(s)
for _ in range(M):
  s = input()
  B.append(s)

for x in range(N-M+1):
  for y in range(N-M+1):
    if all(A[y+j][x:x+M] == B[j] for j in range(M)):
      print("Yes"); exit()

print("No")

Solution (Python):
N, M = map(int, input().split())
L1 = [input() for x in range(N)]
L2 = [input() for x in range(M)]
LL = []
for i in range(N-M+1):
    for j in range(N-M+1):
        a = []
        for y in range(M):
            a += [L1[j+y][i:i+M]]
            pass
        LL += [a]
print('Yes' if sum(1 for x in LL if x == L2)>0 else 'No')

Solution (Python):
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    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 i in range(N - M + 1):
        for j in range(N - M + 1):
            for k in range(M):
                s1 = A[i + k][j:j + M]
                s2 = B[k]
                if s1 != s2:
                    break
            else:
                print('Yes')
                return None

    print('No')


if __name__ == '__main__':
    solve()

Solution (Python):
import sys

N , M = [int(n) for n in input().split()]

A=[]
B=[]
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):
        corres = True
        for k in range(M):
            if A[i+k][j:j+M] != B[k]:
                corres = False
                break
        if corres == True:
            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)]
def _search(i, j):
    flag = True
    for k in range(M):
        for l in range(M):
            flag &= A[i+k][j+l] == B[k][l]
            if not flag:
                return flag
    return flag

def search():
    for i in range(N-M+1):
        for j in range(N-M+1):
            if _search(i, j):
                return 'Yes'
    return 'No'
print(search())

Solution (Python):

import sys
a=[]
b=[]
N,M=map(int ,raw_input().split())
for i in range(N):
    a.append(list(raw_input()))
for i in range(M):
    b.append(list(raw_input()))

def chk(a,b,x,y):
    global M
    global N
    
    
    for row in range(M):
        for col in range(M):
            if a[row+y][col+x]!= b[row][col]:
                return False
    return True

f=False
for row in range(N-M):
    for col in range(N-M):
        if chk(a,b,col,row):
            f=True
if N==1 and M==1 and a[0][0]==b[0][0]:
    print "Yes"
elif f:
    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)]

res=False
for i in range(n-m+1):
    for j in range(n-m+1):
        t=[r[j:j+m] for r in a[i:i+m]]
        res|=t==b
print('Yes' if res else 'No')

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

res = False
for sy in range(N - M + 1):
    for sx in range(N - M + 1):
        ok = True
        for dy in range(M):
            y = sy + dy
            a = A[y][sx:sx + M]
            ok = ok and a == B[dy]
        res = res or ok
print("Yes" if res else "No")

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

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

ball = ''.join(b)

def check():
    for i in range(n):
        if i + m > n:
            continue

        for j in range(n):
            if j + m > n:
                continue

            aall = ""
            for k in range(m):
                aall += a[i+k][j:j+m]

            if aall == ball:
                return True

    return False

ret = "Yes" if check() else "No"
print(ret)

Solution (Python):
N, M = map(int, raw_input().split())
A = [None] * N
for i in xrange(N):
    A[i] = list(raw_input())
B = [None] * M
for i in xrange(M):
    B[i] = list(raw_input())


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

found = False
for y in xrange(N - M + 1):
    for x in xrange(N - M + 1):
        if find(x, y):
            found = True
            break
    if found:
        break
print 'Yes' if found else 'No'

Solution (Python):



from fractions import gcd

def readln():
    _res = list(map(int,str(input()).split(' ')))
    return _res

def readpic(n):
    res = [[0 for j in range(0,n)]for i in range(0,n)]
    for i in range(0,n):
        t = str(input())
        for j in range(0,n):
            if t[j] == '
                res[i][j] = 1
            else:
                res[i][j] = 0
    return res

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

a = readln()
n,m = a[0],a[1]
a = readpic(n)
b = readpic(m)
ans = "No"
for i in range(0,n-m+1):
    for j in range(0,n-m+1):
        if test(i,j):
            ans = "Yes"
print(ans)

Solution (Python):
def check(y,x):
    if 0<=y<=n-1 and 0<=x<=n-1:
        return True
    return False

n,m=map(int,raw_input().split())
a=[raw_input() for _ in xrange(n)]
b=[raw_input() for _ in xrange(m)]
for i in xrange(n):
    for j in xrange(n):
        cnt=0
        for k in range(m):
            for l in xrange(m):
                if check(k+i,l+j):
                    if a[k+i][l+j]==b[k][l]:
                        cnt+=1
        if cnt==m*m:
            print("Yes")
            exit()
print("No")

Solution (Python):


N, M = map(int, input().split())
As = []
Bs = []

ret = 'No'
for n in range(N):
    As.append(input())
for m in range(M):
    Bs.append(input())

for i in range(N-M+1):
    for j in range(N-M+1):
        same = True
        for k in range(M):
            if As[i+k][j:j+M] != Bs[k]:
                same = False
                break
        if same:
            ret = 'Yes'
print(ret)

Solution (Python):

def f(a, b):
    for x in range(n - m + 1):
        for y in range(n - m + 1):
            ok = True
            for i in range(m):
                for j in range(m):
                    if b[i][j] != a[i + x][j + y]:
                        ok = False
                    if not ok:
                        break
                if not ok:
                    break
            if ok:
                return 'Yes'
    return 'No'


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

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

Solution (Python):
n, m = map(int, raw_input().split())
A = [raw_input() for i in xrange(n)]
B = [raw_input() for i in xrange(m)]

for i in xrange(n-m+1):
    for j in xrange(n-m+1):
        ok = 1
        for x in xrange(m):
            for y in xrange(m):
                if A[i+x][j+y] != B[x][y]:
                    ok = 0
        if ok:
            print "Yes"
            exit(0)
print "No"

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

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

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

main()

Solution (Python):


import itertools


def judge(n, m, fig_a, fig_b):
    for dr, dc in itertools.product(range(n - m + 1), repeat=2):
        g = itertools.product(range(m), repeat=2)
        if all(fig_a[r0 + dr][c0 + dc] == fig_b[r0][c0] for r0, c0 in g):
            return True
    return False


def main():
    n, m = (int(x) for x in input().split())
    fig_a = [[c == "
    fig_b = [[c == "
    print("Yes" if judge(n, m, fig_a, fig_b) else "No")


if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin

n, m = map(int, stdin.readline().split())
A = []
B = []
for _ in range(n):
    A.append(stdin.readline().strip())
for _ in range(m):
    B.append(stdin.readline().strip())


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

    x_shift = len(A[0]) - len(B[0])
    y_shift = len(A) - len(B)
    for x in range(0, x_shift+1):
        for y in range(0, y_shift+1):
            result = cmp(A, B, x, y)
            if result:
                return True
    return False

if is_in(B, A):
    print('Yes')
else:
    print('No')

Solution (Python):

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

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

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

ans = False

for i in range(n - m + 1):
    for j in range(n - m + 1):
        _a = a[i:i+len(b)]
        _a = list(map(lambda x: x[j:j+len(b)], _a))

        if b == _a:
            ans = True

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

Solution (Python):
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

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

def main():
    n, m = reads();
    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 check(i, j, a, b):
                print('Yes')
                return
    print('No')
 
main()

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

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

    for i in range(n-m+1):
        for j in range(n-m+1):
            same = True
            for y in range(m):
                for x in range(m):
                    if a[i+y][j+x] != b[y][x]:
                        same = False

            if same:
                return 'Yes'

    return 'No'

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

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

ans=False
for i in range(n-m+1):
    for j in range(n-m+1):
        flag=True
        for mi in range(m):
            for mj in range(m):
                if a[i+mi][j+mj]!=b[mi][mj]:
                    flag=False
        if flag:
            ans=True

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