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.



Sample input:
3 2
#.#
.#.
#.#
#.
.#


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
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):
    if (b[0] in a[i]):
        fir = a[i].index(b[0])
        for j in range(m-1):
            temp = a[i+1][fir:(fir+n-1)]
            if (temp == b[j+1]):
                if (j+1 == m-1):
                    ans = "Yes"
            else:
                break

print(ans)

Submission status: Wrong Answer

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

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:j+M] ==B[0]:
            for k in range(1,M):
                if A[i+k][j:j+M] != B[k]:
                    break
            ans='Yes'
            break

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]
AA = []
for _ in range(N):
    AA.append(input())
BB = []
for _ in range(M):
    BB.append(input())

for i in range(N - M + 1):
    for j in range(N - M + 1):
        for k in range(M):
            for l in range(M):
                if AA[i + k][j + l] != BB[k][l]:
                    break
            else:
                continue
            break
        else:
            print("Yes")
            exit()
        break

print("No")

Submission status: Wrong Answer

Solution code:
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):
    for j in range(n - m):
        flg = False
        for k in range(m):
            if flg:
                break
            for l in range(m):
                if b[k][l] != a[i + k][j + l]:
                    flg = True
                    break
        
        if flg:
            pass
        else:
            print('Yes')
            sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
a = [readline().rstrip().decode() for _ in range(n)]
b = [readline().rstrip().decode() for _ in range(m)]
for y in range(n - m):
    for x in range(n - m):
        flag = True
        for i in range(m):
            for j in range(m):
                if a[i + y][j + x] != b[i][j]:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

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

flag=0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(M):
      if A[i+k][j:j+M]!=B[k]:
        break
      #print(i,j,k,' ',A[i+k][j:j+M],' ',B[k])
    else:
      flag=1
      print('!')
print('Yes' if flag==1 else 'No')

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    A = [readline().rstrip() for _ in range(N)]
    B = [readline().rstrip() for _ in range(M)]
    for h in range(N-M):
        for w in range(N-M):
            a = [l[w:w+M] for l in A[h:h+M]]
            if a == B:
                print('Yes')
                return

    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

flg = False
for y in range(N-M+1):
  for x in range(N-M+1):
    res = True
    for i in range(M):
      if A[y+i][y+i:y+i+M] != B[i][i:i+M]: res = False
    if res: flg = True
    if flg: break
  if flg: break

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

Submission status: Wrong Answer

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

flg = False
for y in range(N-M+1):
  for x in range(N-M+1):
    res = True
    for i in range(M):
      if A[y+i][y+i:y+i+3] != B[i][i:i+3]: res = False
    if res: flg = True
    if flg: break
  if flg: break

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

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
A = [str(input()) for _ in range(N)]
B = [str(input()) for _ in range(M)]
 
res = "No"

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
      if(k==M-1):
        res="yes"
          
print(res)

Submission status: Wrong Answer

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

res = "No"

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:j+M] == B[0]:
            for k in range(1,M):
                if A[i+k][j:j+M] == B[k]:
                    res = "Yes"
                    pass
                else:
                    res = "No"
                    break

print(res)

Submission status: Wrong Answer

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

res = "No"

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:j+M] == B[0]:
            for k in range(1,M):
                if A[i+k][j:j+M] == B[k]:
                    pass
                else:
                    continue
                break
            res = "Yes"

print(res)

Submission status: Wrong Answer

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

res = "No"

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:j+M] == B[0]:
            for k in range(1,M):
                if A[i+k][j:j+M] == B[k]:
                    pass
                else:
                    break
            res = "Yes"

print(res)

Submission status: Wrong Answer

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

res = "No"

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:j+M] == B[0]:
            for k in range(1,M):
                if A[j+k][j:j+M] == B[k]:
                    pass
                else:
                    break
            res = "Yes"

print(res)

Submission status: Wrong Answer

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

res = "No"

for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:j+M] == B[0]:
            for k in range(1,M):
                if A[k][j:j+M] == B[k]:
                    pass
                else:
                    break
            res = "Yes"

print(res)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    A, B = ['']*N, ['']*M
    for i in range(N):
        A[i] = input()
    for i in range(M):
        B[i] = input()
    ans = False
    len_a = len(A[0])
    len_b = len(B[0])
    for i in range(N - M):
        for j in range(len_a - len_b):
            match = True
            for k in range(M):
                a = A[i + k]
                b = B[k]
                if a[j:j+len_b] != b:
                    match = False
            if match:
                ans = True
                break
        if ans:
            break
    print('Yes' if ans else 'No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

n,m = map(int,input().split())
li = [input() for i in range(n)]
li2 = [input() for i in range(m)]
li3 = []
for i in range(n - m + 1):
    d = []
    for j in range(n - m + 1):
        c = ""
        for k in range(m):
            c += li[i][j+k]
        d.append(c)
    li3.append(d) 

for i in range(len(li3)):
    for j in range(len(li3)):
        flag = False
        for k in range(len(li2)):
            if li3[i][j] == li2[k]:
                flag = True
        if flag == True:
            print("Yes")
            sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
def judge(A,B,n,m):
    C = []
    for i in range(n-m+1):
        for j in range(n-m+1):
            C = [A[i][j:m+j] for i in range(m+i)]
            if B == C:
                return True
    return False

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

    if judge(A,B,N,M):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def judge(A,B,n,m):
    C = []
    for i in range(n-m):
        for j in range(n-m):
            C = [A[i][j:m+j] for i in range(m+i)]
            if B == C:
                return True
    return False

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

    if judge(A,B,N,M):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

wA = len(A[0])
wB = len(B[0])
res = "No"

for i in range(N-M+1):
    for j in range(wA-wB+1):
        if A[i][j:j+wB] == B[0]:
            for k in range(1,M):
                if A[k][j:j+wB] == B[k]:
                    pass
                else:
                    break
            res = "Yes"

print(res)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
A = [list(input()) for _ in range(n)]
B = [list(input()) for _ in range(m)]
ans = False
for i in range(n-m+1):
    for j in range(n-m+1):
        flg = True
        for e, k in enumerate(range(m)):
            if A[i+e][j:j+m+1] != B[k]:
                flg = False
        if flg:
            ans = True
            break
print('Yes' if ans else 'No')

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
A = [list(input()) for _ in range(n)]
B = [list(input()) for _ in range(m)]
ans = False
for i in range(n-m+1):
    for j in range(n-m+1):
        flg = True
        for e, k in enumerate(range(m)):
            if A[i+e][j:j+m+1] != B[k]:
                flg = False
        if flg:
            ans = True
            break
print('YES' if ans else 'NO')

Submission status: Wrong Answer

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

wA = len(A[0])
wB = len(B[0])
res = "No"

for i in range(N-M):
    for j in range(wA-wB):
        if A[i][j:j+wB] == B[0]:
            for k in range(1,M):
                if A[k][j:j+wB] == B[k]:
                    pass
                else:
                    break
            res = "Yes"

print(res)

Submission status: Wrong Answer

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

cnt=0
Yes=False
for i in nl:
    if(ml[0] in i):
        idx = i.find(ml[0])
        cnt2=cnt+1
        for j in range(1,m):
            if cnt2>n-1:
                break
            elif(not ml[j]==nl[cnt2][idx:idx+m]):
                break
            elif(j==m-1):
                Yes = True
                break
            cnt2+=1
    if(Yes):
        break
    cnt+=1
if Yes:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

cnt=0
Yes=False
for i in nl:
    if(ml[0] in i):
        print(str(ml[0])+" in "+ str(i))
        idx = i.find(ml[0])
        cnt2=cnt+1
        for j in range(1,m):
            if cnt2>n-1:
                break
            elif(not ml[j]==nl[cnt2][idx:idx+m]):
                break
            elif(j==m-1):
                Yes = True
                break
            cnt2+=1
    if(Yes):
        break
    cnt+=1
if Yes:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

cnt=0
Yes=False
for i in nl:
    if(ml[0] in i):
        idx = i.find(ml[0])
        cnt2=cnt+1
        for j in range(1,m):
            if cnt2>n-1:
                ok = False
                break
            elif(not ml[j]==nl[cnt2][idx:idx+m]):
                ok=False
                break
            elif(j==m-1):
                Yes = True
                break
            cnt2+=1
    if(Yes):
        break
    cnt+=1
if Yes:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])

T = N - M + 1

for i in range(T):
    for j in range(T):
        if np.sum(A[i:i+M, j:j+M] == B):
            print('Yes')
            exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
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):
    if a[i:i+m][j:j+m] == b:
      print('Yes')
      sys.exit()
print('No')

Submission status: Wrong Answer

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

res=0
for i in range(0,n-m+1):
  keep=0
  for k in range(0,n-m+1):
    for j in range(i,i+m):    
      if b[j-i][k:k+m] in a[j][k:k+m]:
        keep+=1
      if keep==m:
        print("Yes")
        res=1
        break
  if res==1:
    break
if res==0:
  print("No")

Submission status: Wrong Answer

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

res=0
for i in range(0,n-m+1):
  keep=0
  for j in range(i,i+m):
    if b[j-i] in a[j]:
      keep+=1
  if keep==m:
    print("Yes")
    res=1
    break
if res==0:
  print("No")

Submission status: Wrong Answer

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

res=0
for i in range(0,n-m+1):
  keep=0
  for j in range(i,i+m):
    if b[j-i] in a[j]:
      keep+=1
  if keep==m:
    print("Yes")
    break
if keep!=m:
  print("No")

Submission status: Wrong Answer

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

res=0
for i in range(0,n-m+1):
  keep=0
  for j in range(i,i+m):
    if b[j-i] in a[j]:
      keep=1
      break
  if keep==1:
    print("Yes")
    break
if keep==0:
  print("No")

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=[list(input()) for _ in range(N)]
B=[list(input()) for _ in range(M)]
grand_flg=0
for i in range(N-M): #i=横スライド
    for j in range(N-M): #j=縦スライド
        flg=1
        for k in range(M): #B横
            for l in range(M): #B縦
                if A[i+k][j+l]!=B[k][l]:
                    flg=0
        if flg==1:
            grand_flg=1

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

Submission status: Wrong Answer

Solution code:
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 j in range(M):
    B[j] = input()
for k in range(N-M):
    for l in range(N-M):
        f = 0
        for p in range(M):
            for q in range(M):
                if not A[k+p][l+q] == B[p][q]:
                    f = 1
                    break
            if f == 1:
                break
        if f == 0:
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

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

for i in range(n-m):#二回
    for j in range(n-m):#二回
        jugh=True
        #print(m+i)
        for x in range(m):
            for y in range(m):
         #       print(x,y)
                if a[x+i][y+j]!=b[x][y]:
                    jugh=False
                   # print(x,y)
                    break
        if jugh==True:
            print("Yes")
            exit()

print("No")

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ai = [input() for i in range(n)]
bi = [input() for i in range(m)]

flag = False

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

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

Submission status: Wrong Answer

Solution code:
def resolve():
	n, m = map(int, input().split())
	A = []
	B = []
	ans = False
	for _ in range(n):
		A.append(list(input()))
	for _ in range(m):
		B.append(list(input()))
	for i in range(n):
		for j in range(n):
			if i + m - 1 >= n or j + m - 1 >= n:
				continue
			tmp_ans = True
			for k in range(m):
				for l in range(m):
					if A[i+k][j+l] != B[k][l]:
						tmp_ans = False
						break
			ans = tmp_ans


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

Submission status: Wrong Answer

Solution code:
def resolve():
	n, m = map(int, input().split())
	A = []
	B = []
	ans = False
	for _ in range(n):
		A.append(list(input()))
	for _ in range(m):
		B.append(list(input()))
	for i in range(n):
		for j in range(n):
			if i + m > n or j + m > n:
				continue
			tmp_ans = True
			for k in range(m):
				for l in range(m):
					if A[i+k][j+l] != B[k][l]:
						tmp_ans = False
						break
			ans = tmp_ans


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

Submission status: Wrong Answer

Solution code:
def resolve():
	n, m = map(int, input().split())
	A = []
	B = []
	ans = "No"
	for _ in range(n):
		A.append(list(input()))
	for _ in range(m):
		B.append(list(input()))
	for i in range(n):
		for j in range(n):
			if i + m > n or j + m > n:
				continue
			tmp_ans = True
			for k in range(m):
				for l in range(m):
					if A[i+k][j+l] != B[k][l]:
						tmp_ans = False
						break
			ans = tmp_ans


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

Submission status: Wrong Answer

Solution code:
def resolve():
	n, m = map(int, input().split())
	A = []
	B = []
	ans = "No"
	for _ in range(n):
		A.append(list(input()))
	for _ in range(m):
		B.append(list(input()))
	for i in range(n):
		for j in range(n):
			if i + m >= n or j + m >= n:
				continue
			tmp_ans = True
			for k in range(m):
				for l in range(m):
					if A[i+k][j+l] != B[k][l]:
						tmp_ans = False
						break
			ans = tmp_ans


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

Submission status: Wrong Answer

Solution code:
def resolve():
	n, m = map(int, input().split())
	A = []
	B = []
	ans = "No"
	for _ in range(n):
		A.append(list(input()))
	for _ in range(m):
		B.append(list(input()))
	for i in range(n):
		for j in range(n):
			if i + m - 1 >= n or j + m - 1 >= n:
				continue
			tmp_ans = True
			for k in range(m):
				for l in range(m):
					if A[i+k][j+l] != B[k][l]:
						tmp_ans = False
			ans = tmp_ans


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

Submission status: Wrong Answer

Solution code:
def resolve():
	n, m = map(int, input().split())
	A = []
	B = ''
	ans = "No"
	for _ in range(n):
		A.append(input())
	for _ in range(m):
		B += input()
	for i in range(n-m):
		for j in range(n-m):
			tmp = ''
			for k in range(m):
				tmp += A[i+k][j:j+m]
			if tmp == B:
				ans = 'Yes'
	print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
an = [input() for _ in range(n)]
bn = [input() for _ in range(m)]
lena = len(an[0])
lenb = len(bn[0])
diff = n-m+1
flag = False
for i in range(diff):
    for j in range(diff):
        if [a[j:diff+j] for a in an[i:diff+i]] == bn:
            flag = True
print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
an = [input() for _ in range(n)]
bn = [input() for _ in range(m)]
lena = len(an[0])
lenb = len(bn[0])
diff = n-m+1
flag = False
for i in range(diff):
    for j in range(diff):
        if [a[j:diff+j] for a in an[i:diff+i]] == bn:
            flag = True
            break
    else:
        continue
    break
print('Yes' if flag else 'No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

diff = N - M
for i in range(diff+1):
    for j in range(diff+1):
        flag = True
        for k in range(M):
            print(A[j+k][i:i+M])
            if not (B[k] in A[j+k][i:i+M]):
                flag = False
        if flag:
            print('Yes')
            exit(0)

print('No')

Submission status: Wrong Answer

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

diff = N - M
for i in range(diff+1):
    for j in range(diff+1):
        flag = True
        for k in range(M):
            if not (B[k] in A[j+k][i:i+M]):
                flag = False
        if flag:
            break

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
an = [input() for _ in range(n)]
bn = [input() for _ in range(m)]
lena = len(an[0])
lenb = len(bn[0])
diff = n-m+1
flag = False
for i in range(diff):
    for j in range(diff):
        print([a[j:diff+j] for a in an[i:diff+i]])
        if [a[j:diff+j] for a in an[i:diff+i]] == bn:
            flag = True
            break
    else:
        continue
    break
print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
import sys
n, m = map(int, input().split())
an = [input() for _ in range(n)]
bn = [input() for _ in range(m)]
lena = len(an[0])
lenb = len(bn[0])
yax = n-m+1
xax = lena-lenb+1
for i in range(yax):
    for j in range(xax):
        if [a[j:xax+j] for a in an[i:yax+i]] == bn:
            print('Yes')
            sys.exit()
print('No')

Submission status: Wrong Answer

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

A = [[0]]*N
B = [[0]]*M

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

judge = False 

#行同士で比較していく
for k in range(N-M+1):
    count = 0   
    for j in range(M):
        for i in range(N-M+1):
            if B[j]==A[j+i][k:k+M]:
                count += 1
                
                if count == M:
                    judge = True
                    break
            
if judge == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

A = [[0]]*N
B = [[0]]*M

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

judge = False 

#行同士で比較していく
for k in range(N-M+1):
    count = 0   
    for j in range(M):
        for i in range(N-M+1):
            if B[j]==A[i][k:k+M]:
                count += 1
                
                if count == M:
                    judge = True
                    break
            
if judge == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

A = [[0]]*N
B = [[0]]*M

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

judge = False 

#行同士で比較していく
for k in range(M-N+1):
    count = 0   

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

Submission status: Wrong Answer

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

A = [[0]]*N
B = [[0]]*M

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

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

Submission status: Wrong Answer

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

A = [[0]]*N
B = [[0]]*M

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

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

Submission status: Wrong Answer

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

A = [[0]]*N
B = [[0]]*M

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

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

Submission status: Wrong Answer

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

A = [[0]]*N
B = [[0]]*M

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

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

Submission status: Wrong Answer

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

A = [[0]]*(N+1)
A[N] = str("a")*50
B = [[0]]*M

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

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

Submission status: Wrong Answer

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

A = [[0]]*(N+1)
A[N] = str("a")*50
B = [[0]]*M

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

judge = False 
count = 0   
for i in range(N-M+1):
    for j in range(M-1):
        if B[j]==A[i][i:i+M] and B[j+1]==A[i+1][i:i+M]:
            count += 1
            
            if count == M - 1:
                judge = True
                break
            
print(A[N-M][N-M:N])
if judge == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [""] * N
B = [""] * M

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


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