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):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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

    for y in range(N - M + 1):
        for x in range(N - M + 1):
            ok = True
            for i in range(M):
                for j in range(M):
                    ok &= A[y + i][x + j] == B[i][j]

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

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

FLG = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        cnt = 0
        for k in range(M):
            if B[k]==A[i+k][j:j+M]:
                cnt += 1
        if cnt==M: FLG = 1

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

Solution (Python):
N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A.append(list(input()))
for j in range(M):
    B.append(list(input()))
import copy
CA = copy.deepcopy(B)
ans = -1
for i in range(N - M + 1):
    for l in range(N - M + 1):
        for j in range(M):
            for k in range(M):
                CA[j][k] = A[i + j][l + k]
        if CA == B:
            print("Yes")
            ans = 1
            break
    if ans == 1:
        break
if ans == -1:
    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())
  
def match(a,b):
  for i in range(M):
    for j in range(M):
      if A[a+i][b+j] != B[i][j]:
        return False  
  return True

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

Solution (Python):

from __future__ import unicode_literals
from __future__ import print_function
import sys
import string


def find_text(line, pattern_id, pattern):
    correspond = []
    for i in range(len(line)):
        s = line[i:i+len(pattern)]
        if(s == pattern):
            correspond.append(pattern_id)
        else:
            correspond.append(None)
    return correspond

def main():
    lines = [x.replace("\n","") for x in sys.stdin.readlines()]

    n, m = [int(x) for x in string.split(lines[0])]
    image_a = lines[1:n+1]
    image_b = lines[n+1:n+1+m]
    
    corresponds = {}
    for line_index, image_line in enumerate(image_a):
        for next_line, next_image_line in enumerate(image_b):
            
            corresponds[(line_index,next_line)] = find_text(image_line, next_line, next_image_line)
    for j in range(len(corresponds[(0,0)])):
        for i in range(n-(m-1)):
            array = []
            for k in range(m):
                if(corresponds[(i+k,k)][j] == k):
                    array.append(True)
                else:
                    array = []
            if(len(array)==m):
                print("Yes")
                sys.exit(0)
    print("No")

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
n,m=map(int,input().split())
a=[list(input()) for a in range(n)]
b=[list(input()) for a in range(m)]
c=0;d=0
for p in range(n-m+1):
  for q in range(n-m+1):
    if b[0]==a[p][q:q+m]:
      for r in range(m):
        if b[r]!=a[p+r][q:q+m]:d+=1
      if d==0:c=1
      else:d=0
if c==0:print('No')
else:print('Yes')

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

def match(ofs_x, ofs_y):
    for ar,br in zip(A[ofs_y:], B):
        if ar[ofs_x : ofs_x + M] != br:
            return False
    return True

for y in range(N-M+1):
    for x in range(N-M+1):
        if match(x,y):
            print('Yes')
            exit()
print('No')

Solution (Python):

import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())


n,m = li()
a = []
b = []
for _ in range(n):
    a.append(ns())
for _ in range(m):
    b.append(ns())


contain = False
for row in range(n-m+1):
    for col in range(n-m+1):
        match = True
        for r in range(m):
            if a[row+r][col:col+m] != b[r]:
                match = False
                
        if match:
            contain = True
            
if contain:
    print("Yes")
else:
    print("No")

Solution (Python):
N,M = map(int,input().split())
A = []
B = []
for i in range(N):
    line = input()
    A.append(line)
for j in range(M):
    line = input()
    B.append(line)
res = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        counter = 0
        for k in range(M):
            if B[k] != A[k+j][i:i+M]:
                break
            counter +=1
        if counter == M:
            res +=1
if res >=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)]
for i in range(n-m+1):
    for j in range(n-m+1):
        count = 0
        for k in range(i, i+m):
            if a[k][j:m+j] == b[k-i]:
                count += 1
        if count == m:
            print('Yes')
            exit()
print('No')

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

Solution (Python):

"""
Created on Sun Aug 26 11:25:55 2018

@author: maezawa
"""

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

yesno = 0
for x in range(n-m+1):
    for y in range(n-m+1):
        flag = 0
        i = 0
        while a[x+i][y:y+m] == b[i]:
            
            i += 1
            if i == m:
                flag = 1
                break
        if flag == 1:
            yesno = 1
            break
    if yesno == 1:
        break
    
if yesno == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

N, M = (int(i) for i 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):
    if B[0] in A[i]:
        pos = A[i].find(B[0])
        flag = 0
        for j in range(M):
            if A[i+j][pos:pos+M] == B[j]:
                pass
            else:
                flag = -1
                break
        if flag == 0:
            print("Yes")
            sys.exit()

print("No")

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

aList = []
bList = []
aListSlice = []
answer = 'No'

for i in range(n):
    aList = aList + list(input())

for j in range(m):
    bList = bList + list(input())

for right in range(n-m+1):
    for down in range(n-m+1):
        for k in range(m):
            idx = n*(k+down)+right
            aListSlice = aListSlice + aList[idx:idx+m]
        if bList == aListSlice:
            answer = 'Yes'
            break
        aListSlice = []
    if answer == 'Yes':
        break

print(answer)

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

a = [input() for w in range(N)]
b = [input() for w in range(M)]

message = "No"

for i in range(N + M - 1):
    for j in range(N + M - 1):
        s = [t[j:j+M] for t in a[i:i+M]]
        if s == b:
            message = "Yes"
            break

print(message)

Solution (Python):
n, m = map(int, input().split())
ary_n = [input() for _ in range(n)]
s = "".join([input() for _ in range(m)])

ret = "No"
for x in range(n - m + 1):
    tmp = ""
    for y in range(n):
        tmp += ary_n[y][x:x+m]
    if tmp.find(s) >= 0:
        ret = "Yes"
        break
print(ret)

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):
        t = [k[j:j+m] for k in a[i:i+m]]
        if t==b:
            print('Yes')
            exit()
print('No')

Solution (Python):
import numpy as np
N, M = map(int, input().split())
A = np.array([[j for j in input()] for i in range(N)])
B = np.array([[j for j in input()] for i in range(M)])
ans = 'No'
for l in range(N-M+1):
    for d in range(N-M+1):
        if np.array_equal(A[l:l+M,d:d+M], B):
            ans = 'Yes'
print(ans)

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

Solution (Python):


def main():
    n, m = map(int, input().split())
    graph_a = [list(input()) for _ in range(n)]
    graph_b = [list(input()) for _ 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 graph_a[s+p][t+q] != graph_b[p][q]:
                        check = False
            if check:
                flag = True
    
    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):
def func():
  n,m=map(int,input().split())
  o=[input() for _ in range(n)]
  p=[input() for _ in range(m)]
  q=[]
  for i in range(n-m+1):
    for j in range(n-m+1):
      fl=True
      for k in range(m):
        for l in range(m):
          if p[k][l]!=o[i+k][j+l]:
            fl=False
      q.extend([fl])
  return q

a=func()
if sum(a):
  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:
            print('Yes')
            exit()
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())

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

Solution (Python):
n, m = list(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):
        ans = True
        for k in range(m):
            if b[k] != a[i+k][j:j+m]:
                ans = False
        if ans:
            print('Yes')
            break
    if ans:
        break
if not ans:
    print('No')

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

for y in range(n-m+1):
    for x in range(n-m+1):
        if [line[x:x+m] for line in a[y:y+m]] == b:
            print("Yes")
            exit()
print("No")

Solution (Python):
import numpy as np
a,b=map(int,input().split())
def sn(x):
  if x==".":
    return 0
  else:
    return 1
c=np.array([list(map(sn,list(input()))) for i in range(a)])
d=np.array([list(map(sn,list(input()))) for i in range(b)])

for i in range(a-b+1):
  for j in range(a-b+1):
    if np.allclose(c[i:b+i,j:b+j],d):
      print("Yes")
      exit()
else:
  print("No")

Solution (Python):


















''' 二次元配列を一列ずつ
for i in ans:
	print(*i)
'''
''' heapq
queue = []
heapq.heapify(queue) 
heapq.heappush(queue,num) 
pop = heapq.heappop(queue) 
pop = heapq.heappushpop(queue,num) 

'''

from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7


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

AA = [list(input()) for i in range(N)]
BB = [list(input()) for i in range(M)]

d = N - M

def check(x,y):
	for xx in range(0,M):
		for yy in range(0,M):
			if BB[yy][xx] != AA[yy+y][xx+x]:
				return False
	return True


for x in range(d+1):
	for y in range(d+1):
		if check(x,y):
			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 r in range(n-m+1):
    for c in range(n-m+1):
        flg = True
        for i in range(m):
            for j in range(m):
                if B[i][j] != A[i+r][j+c]:
                    flg = False
                    break
        if flg:
            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)]

cur = 0

res = False

for r in range(n):
    offset = -1
    while True:
        offset = a[r].find(b[0], offset + 1)

        if offset == -1:
            break

        flg = True
        for r2 in range(1, m):
            if r + r2 >= n:
                flg = False
                break
            if a[r + r2].find(b[r2], offset) != offset:
                flg = False
                break

        if flg == True:
            res = True
            break

    if res == True:
        break
            
if res == True: print("Yes")
else: print("No")

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

a=[]

for i in range(n):
    tmp=list(input())
    d=[-1]*n
    for j in range(n):
        if tmp[j]=="
            d[j]=1
    a.append(d)

b=[]

for i in range(m):
    tmp=list(input())
    d=[-1]*m
    for j in range(m):
        if tmp[j]=="
            d[j]=1
    b.append(d)
    
ans="No"

for i in range(n-m+1):
    for j in range(n-m+1):
        flag=1
        for k in range(m):
            for l in range(m):
                x=i+k
                y=j+l
                if a[y][x]*b[k][l]<0:
                    flag=-1
        if flag==1:
            ans="Yes"


print(ans)

Solution (Python):
n,  m = map(int, input().split())
np = [input() for _ in range(n)]
mp = [input() for _ in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    f = True
    for k in range(m):
      if np[i+k][j:j+m] != mp[k]:
        f = False
    if f:
      print("Yes")
      exit(0)
else:
  print("No")

Solution (Python):
import numpy as np


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

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

for i in range(N - M + 1):
    for j in range(N - M + 1):
        if np.array_equal(A_arr[i:i + M, j:j + M], B_arr):
            print('Yes')
            exit()

print('No')

Solution (Python):
import sys

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

for ai in range(n - m + 1):
    for aj in range(n - m + 1):
        can = True
        for bi in range(m):
            if a[ai+bi][aj:aj+m] != b[bi]:
                can = False
                break
        if can:
            print('Yes')
            sys.exit(0)

print('No')

Solution (Python):
n, m = list(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 = False
    for k in range(m):
      for l in range(m):
        if a[i+k][j+l]==b[k][l]:
          pass
        else:
          flag = True
          break
      if flag:
        break
    if flag==False:
      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)]
def match(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
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):
import numpy as np
n, m = map(int, input().split())

img = np.array([list(input()) for i in range(n)])
w = img.shape[-1]
template = np.array([list(input()) for i in range(m)])
tw = template.shape[-1]

for y in range(n - m + 1):
    for x in range(w - tw + 1):
        if np.all(img[y:y + m, x:x + tw] == template):
            print("Yes")
            exit()
print("No")

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



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

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

Solution (Python):


n, m = map(int, input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        include = True
        for k in range(m):
            for l in range(m):
                if A[i+k][j+l] != B[k][l]:
                    include = False
        if include:
            print('Yes')
            exit()
print('No')

Solution (Python):
n,m=map(int, input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
ans=0
for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j:j+m]==b[0]:
            t=0
            for k in range(1,m):
                if a[i+k][j:j+m]!=b[k]:
                    t+=1
            if t==0:
                ans+=1
print('Yes' if ans else '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):
            
            if "".join(A[i+k])[j:j+M] != "".join(B[k]):
                break
            
            if k == M - 1:
                print("Yes")
                exit()

print("No")

Solution (Python):
N,M=[int(i) for i in input().split()]
A=[]
for i in range(N):
    a=[i for i in input()]
    A.append(a)
B=[]
for i in range(M):
    b=[i for i in input()]
    B.append(b)    
flag=False
for i in range(N-M+1):
    for j in range(N-M+1):
        s=0
        if B[0][0]==A[i][j]:    
            for k in range(M):
                for l in range(M):
                    if B[0+k][0+l]==A[i+k][j+l]:
                        s+=1
            if s==M**2:
                flag=True          
if flag==True:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

def isin(y, x):
  flag = True
  for i in range(m):
    for j in range(m):
      if image_n[y + i][x + j] != image_m[i][j]:
        flag = False
        
  return flag 

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

image_n = []

for i in range(n):
  image_n.append(input())

image_m = []

for j in range(m):
  image_m.append(input())


for i in range(n - m + 1):
  for j in range(n - m + 1):
    if isin(i, j):
      print("Yes")
      sys.exit()

print("No")

Solution (Python):
from itertools import product
N, M = list(map(int, input().split()))
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]
flag = False

for _i, _j in product(range(N - M + 1), range(N - M + 1)):
    if A[_i][_j] == B[0][0] and [_A[_j:_j+M] for _A in A[_i:_i+M]] == B:
        flag = True
        break
if flag:
    print('Yes')
else:
    print('No')

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

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

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

same = False
for i in range(N-M+1):
    for l in range(N-M+1):
        count = 0
        for j in range(M):
            for k in range(M):
                if B[j][k] == A[j+i][k+l]:
                    count += 1
        if count == M*M:
            same = True
            break



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

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

Solution (Python):
n,m=map(int,raw_input().split())
A=[raw_input() for j in range(n)]
B=[raw_input() for j in range(m)]
def sub(ox,oy):
  for x in xrange(m):
    for y in xrange(m):
      if A[ox+x][oy+y] != B[x][y]:
        return False
  return True
def match():
  for x in xrange(n-m+1):
    for y in xrange(n-m+1):
      if sub(x,y): return True
  return False
if match():
  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)]

cs = ([row[j:j+m] for row in a[i:i+m]] for i in range(n-m+1) for j in range(n-m+1))
print('Yes' if any(c==b for c in cs) 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())

for h in range(N-M+1):
    for w in range(N-M+1):
        if list(map(lambda x:x[w:w+M], A[h:h+M])) == B:
            print("Yes")
            exit()

print("No")

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

Solution (Python):
n, m = [int(i) for i in input().split()]
a = []
for i in range(n):
    tmp = input()
    a.append(tmp)
b = []
for i in range(m):
    tmp = input()
    b.append(tmp)
f = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        g = True
        for k in range(m):
            for l in range(m):
                if a[i + k][j + l] != b[k][l]:
                    g = False
        if g:
            f = True
if 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)]
exits = False

for i in range(n-m+1):
    for j in range(n-m+1):
        p = []
        for k in range(m):
            p.append(a[i:i+m][k][j:j+m])
        if p == b:
            exits = True

print('Yes' if exits else 'No')

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

def match(ofs_x, ofs_y):
    for i in range(M):
        if A[i+ofs_y][ofs_x:ofs_x+M] != B[i]:
            return False
    return True

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

Solution (Python):
import sys
import os

def is_same(a, b):
    for i in range(len(a)):
        if a[i] != b[i]:
            return False
    return True

N, M = list(map(lambda x: int(x), sys.stdin.readline().strip().split(" ")))

A = []
B = []

for _ in range(N):
    A.append(sys.stdin.readline().strip())

for _ in range(M):
    B.append(sys.stdin.readline().strip())

it = N - M + 1

for i in range(it):
    for j in range(it):
        a = list(map(lambda x: x[j:j+M], A[i:i+M]))
        if is_same(a, B):
            print("Yes")
            sys.exit(0)
print("No")

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

flag = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        l = 0
        if T1[i][j: j + m] == T2[l]:
            k = i
            while k < n - m + 1 and l < m:
                if T1[k][j:j + m] != T2[l]:
                    break
                k += 1
                l += 1
                if l == m:
                    flag = True


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

Solution (Python):
n,m=map(int,input().split())
a=[list(input())for i in range(n)]
b=[list(input())for i in range(m)]
def match(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):
        judge=False
        if a[i][j]==b[0][0]:
            if match(i,j):
                judge=True
            if judge:
                print("Yes")
                exit()
print("No")

Solution (Python):
import numpy as np

N, M = map(int, input().split())
n_img = []
m_img = []

for _ in range(N):
    n_img.append([0 if e == '
for _ in range(M):
    m_img.append([0 if e == '

n_img = np.array(n_img)
m_img = np.array(m_img)


def areSameM(m1, m2):
    s = np.sum(np.sum(abs(m1 - m2)))
    return s == 0


flag = False

for i in range(N - M):
    for j in range(N - M):
        if areSameM(n_img[i:i + M, j:j + M], m_img):
            flag = True
            break
    if flag:
        break

if N == M:
    flag = areSameM(n_img, m_img)

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

Solution (Python):






if __name__ == '__main__':
    n, m = list(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):
            is_exist = True

            
            
            for dx in range(m):
                if a[i + dx][j:j + m] != b[dx]:
                    is_exist = False
                    break

            if is_exist:
                print('Yes')
                exit()

    print('No')

Solution (Python):






if __name__ == '__main__':
    n, m = list(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):
            is_exist = True

            for dx in range(m):
                for dy in range(m):
                    if a[i + dx][j + dy] != b[dx][dy]:
                        is_exist = False
                        break

            if is_exist:
                print('Yes')
                exit()

    print('No')

Solution (Python):






if __name__ == '__main__':
    n, m = list(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):
            is_exist = True

            for dx in range(m):
                for dy in range(m):
                    if a[i + dx][j + dy] != b[dx][dy]:
                        is_exist = False

            if is_exist:
                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)]
def match(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
judge=False
for i in range(n-m+1):
    for j in range(n-m+1):
        if match(i,j):
            judge=True
if judge:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
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):
        check = True
        for di in range(M):
            for dj in range(M):
                if A[i+di][j+dj] != B[di][dj]:
                    check = False
        if check:
            print("Yes")
            sys.exit()
else:
    print("No")

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

pic_n, pic_m = [], []
for i in range(n):
    pic_n.append([j for j in input()])
for i in range(m):
    pic_m.append([j for j in input()])

corr = "No"
for i in range(n):
    for j in range(n):
        if pic_n[i][j] == pic_m[0][0]:
            for k in range(m):
                if i + k >= n:
                    break
                for l in range(m):
                    if j + l >= n or pic_n[i+k][j+l] != pic_m[k][l]:
                        break
                else:
                    continue
                break
            else:
                corr = "Yes"

print(corr)