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=[input() for x in range(N)]
B=[input() for x in range(M)]
ans = 'No'
for h in range(0,(N-M)+1):
  for w in range(0,(N-M)+1):
    if sum([B[i]!=A[i+h][w:(w+M+1)] for i in range(M)])==0:
      ans = 'Yes'
      break
  if ans == 'Yes':
    break
print(ans)

Submission status: Wrong Answer

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

ans = 'No'
d = N - M + 1
for i in range(d):
    for j in range(d):
        cnt = 0
        for x in range(M):
            if A[i+x][j:j+M+1] == B[x]:
                cnt += 1
            else:
                break
        if cnt == M:
            ans = 'Yes'

print(ans)

Submission status: Wrong Answer

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

ans = 'No'
d = N - M + 1
for i in range(d):
    for j in range(d):
        cnt = 0
        for x in range(M):
            if A[i+x][j:j+M+1] == B[x]:
                cnt += 1
            else:
                break
        if cnt == M:
            ans = 'Yes'
            break
    if ans == 'Yes':
        break

print(ans)

Submission status: Wrong Answer

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

ans = 'No'
d = N - M + 1
for i in range(d):
    for j in range(d):
        cnt = 0
        for x in range(M):
            if A[i+x][j:M+1] == B[x]:
                cnt += 1
            else:
                break
        if cnt == M:
            ans = 'Yes'
            break
    if ans == 'Yes':
        break

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = [ int(x) for x in input().split() ]
As = [ input() for _ in range(N) ]
Bs = [ input() for _ in range(M) ]

def contain(i, j):
    for p in range(M):
        if As[i + p][j:j+M] != Bs[p]:
            return False
    return True
ans = False
for i in range(N - M):
    for j in range(N - M):
        if contain(i, j):
            ans = True

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

Submission status: Wrong Answer

Solution code:
n,m=[int(i) for i in input().split()]
a=[input() for i in range(n)]
b=[input() for i in range(m)]
result=True
for i in range(m):
    for j in range(len(b[i])):
        if b[i][j]!=a[i][j]:
            result=False
            break
print("Yes" if result else "No")

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = []
A_portion = []
B = []
judge = 0

if(N < M):
  print('No')
else:
 for i in range(N):
   a = input() + '?'*(M)
   A.append(list(a))
 for i in range(M):
   list_dummy = list('?'*(len(a)))
   A.append(list_dummy)
  
 for i in range(M):
   b = input()
   B.append(list(b))

 for i in range(N):
  for j in range(M):
   for k in range(M):
    A_portion.append(A[j+k][i:i+M])
   #print(j+k,i,i+M-1)
   #print(A_portion)
   if(A_portion == B):
     judge = 1
   A_portion = []
    
 if(judge == 1):
   print('Yes')
 else:
   print('No')

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = []
A_portion = []
B = []
judge = 0

if(N < M):
  print('No')
else:
 for i in range(N):
   a = input() + '?'*(M)
   A.append(list(a))
 for i in range(M):
   list_dummy = list('?'*(len(a)))
   A.append(list_dummy)
  
 for i in range(M):
   b = input()
   B.append(list(b))

 for i in range(N):
  for j in range(M):
   for k in range(M):
    A_portion.append(A[j+k][i:i+M])
   print(j+k,i,i+M-1)
   print(A_portion)
   if(A_portion == B):
     judge = 1
   A_portion = []
    
 if(judge == 1):
   print('Yes')
 else:
   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())

ok=False
cf=[]
for i in range(n-m+1):
    for j in range(n-m+1):
        for l in range(m):
            cf.append(a[i+l][j:j+m])
            #print(cf)
    if cf==b:
        ok=True
    cf=[]
print("Yes"if ok else "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())

ok=False
cf=[]
for i in range(n-m+1):
    for j in range(n-m+1):
        for l in range(m):
            cf.append(a[i+l][j:j+m])
            #print(cf)
        if cf==b:
            ok=True
            break
    cf=[]
print("Yes"if ok else "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())

ok=False
cf=[]
for i in range(n-m+1):
    for j in range(n-m+1):
        for l in range(m):
            cf.append(a[l][j:j+m])
            #print(cf)
        if cf==b:
            ok=True
            break
    cf=[]
print("Yes"if ok else "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)]


for j in range(0,n-m+1):
  for k in range(0,n-m+1):
    flag =True
    for row in range(m):
      for clm in range(m):
        if a[row+j][clm+k]!=b[row][clm]:
          flag = False
    if not flag:
      print("Yes")
      exit()
print("No")

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
aa = [input() for _ in range(n)]
bb = [input() for _ in range(m)]

ans = 0
for a in aa:
    for b in bb:
        if a.count(b)>0:
            ans +=1
            break
# print(ans)
print('Yes' if ans==len(bb) else 'No')

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
aa = [input() for _ in range(n)]
bb = [input() for _ in range(m)]

ans = 0
for a in aa:
    for b in bb:
        if a.count(b)>0:
            ans +=1
            break
# print(ans)
print('Yes' if ans==len(aa) else 'No')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n, m = map(int, input().split())
N = [input() for _ in range(n)]
M = [input() for _ in range(m)]
flg = [0, 0]
for i in range(n - m + 1):
    if flg[0] == 1:
        break
    for j in range(n - m + 1):
        for k in range(m):
            if M[k] == N[i + k][j : j + m]:
                flg[1] = 1
            else:
                flg[1] = 0
        if flg[1]:
            flg[0] = 1
            break
print(['No','Yes'][flg[0]])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n, m = map(int, input().split())
N = [input() for _ in range(n)]
M = [input() for _ in range(m)]
flg = [0, 0]
for i in range(n - m + 1):
    for j in range(n - m + 1):
        for k in range(m):
            if M[k] == N[i + k][j : j + m]:
                flg[1] = 1
            else:
                flg[1] = 0
        if flg[1]:
            flg[0] = 1
            break
        else:
            flg[1] = 0
print(['No','Yes'][flg[0]])

Submission status: Wrong Answer

Solution code:
""" AtCoder """

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):
    check = True
    for j in range(N - M + 1):
        count = 0
        for jj in range(M):
            if A[i + jj][j:j + M] != B[jj]:
                check = False
                break
            count += 1
        if count == M:
            print("Yes")
            exit()
        if not check:
            break

print("No")

Submission status: Wrong Answer

Solution code:
""" AtCoder """

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

check = True

for i in range(N - M + 1):
    check = True
    for j in range(M):
        count = 0
        for jj in range(M):
            if A[i + jj][j:j + M] != B[jj]:
                check = False
                break
            count += 1
        if count == M:
            print("Yes")
            exit()
        if not check:
            break

print("No")

Submission status: Wrong Answer

Solution code:
""" AtCoder """

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

check = True

for i in range(N - M + 1):
    check = True
    for j in range(M):
        count = 0
        for jj in range(M):
            if A[i + jj][i + j:i + j + M] != B[jj]:
                check = False
                break
            count += 1
        if count == M:
            print("Yes")
            exit()
        if not check:
            break

print("No")

Submission status: Wrong Answer

Solution code:
""" AtCoder """

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

check = True

for i in range(N - M):
    check = True
    for j in range(M):
        count = 0
        for jj in range(M):
            if A[i + jj][i + j:i + j + M] != B[jj]:
                check = False
                break
            count += 1
        if count == M:
            print("Yes")
            exit()
        if not check:
            break

print("No")

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = []
for _ in [0]*N:
    A.append(list(input().rstrip()))
B = []
for _ in [0]*M:
    B.append(list(input().rstrip()))

def check(x, y):
    for s in range(M):
        for t in range(M):
            if A[x+s][y+t] == B[s][t]:
                continue
            else:
                return False
    return True

def main():
    for x in range(N-M):
        for y in range(N-M):
            if check(x, y):
                print('Yes')
                return
    print('No')
    return

main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[]
b=[]
c=0
for i in range(n):
    a.append(input())
for j in range(m):
    b.append(input())
for m in range(len(a)):
    if a[m].find(b[0])!=-1:
        print(1)
        for l in range(len(b)-1):
            if m+l+2>len(a):
                break
            if a[m+l+1][(a[m].find(b[0])):(a[m].find(b[0]))+len(b[l+1]):]!=b[l+1]:
                break
            c+=1
            print(c)
        if c==len(b)-1:
            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)]
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            h = True
            if a[i+k][j:j+m] != b[k]:
                h = False
        if h:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

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


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

flg = False

for i in range(N - M):
    for j in range(N - M):
        if match(i, j):
            flg = True

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

Submission status: Wrong Answer

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


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

flg = False

for i in range(N - M):
    for j in range(N - M):
        if match(i, j):
            flg = True

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

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())
judge="No"
for i in range(n-m+1):
  if B[0] in A[i]:
    for j in range(1,m):
      if not  B[j] in A[i+j]:
        break
    judge="Yes"
print(judge)

Submission status: Wrong Answer

Solution code:
[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())

#0,0からm,mまでの全てについて、合致するかどうかを全てのパターンでみる
#2*2だとして、3*3なら4個、4*4なら9個
#→差+1個あると考えて良さそう
ok = 1
for i in range(m):
  for j in range(m):
    for k in range(n - m + 1):
      for l in range(n - m + 1):
        if a[i+k][j+l] != b[i][j]:
          ok = 0

if ok == 0:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int,input().split())
L1,L2=[],[]
for s in range(n):
  L1.append(list(input()))
for s in range(m):
  L2.append(list(input()))
L1,L2=np.array(L1),np.array(L2)
for s in range(n-m):
  for t in range(n-m):
    if np.any(L1[s:s+m,t:t+m]==L2):
      print("Yes")
      exit()
print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

            if flag==0:
                break

        else:
            print("Yes")
            sys.exit()


else:
    print("No")

Submission status: Wrong Answer

Solution code:
int_n, int_m = map(int, input().split())

li_a = list()
li_b = list()

for i in range(int_n):
    li_a.append(input())

for i in range(int_m):
    li_b.append(input())


for x in range(int_n - int_m):
    for y in range(int_n - int_m):
        li_w = [a[0 + x: int_m + x] for a in li_a[0 + y: int_m + y]]

        if "/".join(li_w) == "/".join(li_b):
            print("Yes")
            exit(0)
else:
    print("No")

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())
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        flag = 0
        for k in range(m):
            if A[j + k][i:] == B[k][:]:
                flag = 1
                continue
            flag = 0
            break
        if flag == 1:
            print('Yes')
            exit(0)
print('No')

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())
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        for k in range(m):
            if A[j + k][i:] == B[k][:]:
                flag = 1
                continue
            flag = 0
            break
        if flag == 1:
            print('Yes')
            exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
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())
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        for k in range(m):
            if A[j + k][i:] == B[k][:]:
                flag = 1
                continue
            flag = 0
            break
        if flag == 1:
            print('Yes')
            exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
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())
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        if A[j][i:] == B[0][:]:
            for k in range(m):
                if A[j + k][i:] == B[k][:]:
                    flag = 1
                    continue
                flag = 0
                break
            if flag == 1:
                print('Yes')
                exit(0)
print('No')

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()])
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        flag = 1
        for k in range(m):
            if A[j + k][i: i + m] != B[k]:
                flag = 0
                break
        if flag == 1:
            print('Yes')
            exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
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()])
# if m > n:
#     print('No')
#     exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        flag = 1
        for k in range(m):
            if A[j + k][i: i + m] != B[k]:
                flag = 0
                break
        if flag == 1:
            print('Yes')
            exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
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()])
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        flag = 1
        for k in range(m):
            if A[j + k][i: i + m] != B[k]:
                flag = 0
                break
        if flag == 1:
            print('Yes')
            exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
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()])
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        for k in range(m):
            if A[j + k][i: i + m] == B[k]:
                flag = 1
                continue
            flag = 0
            break
        if flag == 1:
            print('Yes')
            exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
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()])
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        for k in range(m):
            if A[j + k][i: i + m] == B[k][:]:
                flag = 1
                continue
            flag = 0
            break
        if flag == 1:
            print('Yes')
            exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
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()])
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        if A[j][i: i + m] == B[0][:]:
            for k in range(m):
                if A[j + k][i: i + m] == B[k][:]:
                    flag = 1
                    continue
                elif A[j + k][i: i + m] != B[k][:]:
                    flag = 0
                    break
            if flag == 1:
                print('Yes')
                exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
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()])
# if m > n:
#     print('No')
#     exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        if A[j][i: i + m] == B[0][:]:
            for k in range(m):
                if A[j + k][i: i + m] == B[k][:]:
                    flag = 1
                    continue
                flag = 0
                break
            if flag == 1:
                print('Yes')
                exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
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()])
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        if A[j][i: i + m] == B[0][:]:
            for k in range(m):
                if A[j + k][i: i + m] == B[k][:]:
                    flag = 1
                    continue
                flag = 0
                break
            if flag == 1:
                print('Yes')
                exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
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()])
if m > n:
    print('No')
    exit(0)
for j in range(n - m + 1):
    for i in range(n - m + 1):
        if A[j][i:] == B[0][:]:
            for k in range(m):
                if A[j + k][i:] == B[k][:]:
                    flag = 1
                    continue
                flag = 0
                break
            if flag == 1:
                print('Yes')
                exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
import sys
n, m = map(int, input().split())
image = []
temp = []
match = False
for i in range(n):
  image.append(input())
for i in range(m):
  temp.append(input())
for i in range(n):
  for j in range(n - m + 1):
    if (temp[0] == image[i][j : j + m]):
      match = True
      for k in range(1, m):
        if ((temp[k] != image[i + k][j : j + m]) & (i + k >= n)):
          match = False
          break
      if (match == True):
        print('Yes')
        sys.exit()
print('No')

Submission status: Wrong Answer

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

for i in range(N-M+1):
  count = 0
  for j in range(N-M+1):
    for k in range(M):
        if N_[i][j:j+M+1] == M_[k]:
          count = count + 1
    if count == M:
      break
  else:
      continue
  break
if count == M:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

count = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(M):
        if N_[i][j:j+M+1] == M_[k]:
          count = count + 1
    if count == M:
      break
  else:
      continue
  break
if count == M:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

count = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(M):
      if N_[i+k][j:j+M+1] == M_[k] and count != M:
        count = count + 1
        
if count == M:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

count = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(M):
      if N_[i+k][j:j+M+1] == M_[k]:
        count = count + 1
    if count == M:
      break
if count == M:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

for i in range(N-M+1):
  count = 0
  for j in range(N-M+1):
    for k in range(M):
      if N_[i+k][j:j+M+1] == M_[k]:
        count = count + 1
    if count == M:
      break
if count == M:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

count = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(M):
      if N_[i][j:j+M+1] == M_[k]:
        count = count + 1
    if count == M:
      break
if count == M:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

for i in range(N-M+1):
  count = 0
  for j in range(N-M+1):
    for k in range(M):
      if N_[i][j:j+N+1] == M_[k]:
        count = count + 1
    if count == M:
      break
if count == M:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

count = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(M):
      if N_[i][j:j+N+1] == M_[k]:
        count = count + 1
    if count == M:
      break
if count == M:
  print('Yes')
else:
  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)]

f=False
for i in range(n-m+1):
    for j in range(n-m+1):
        
        sc=0
        for k in range(i,i+m):
            for l in range(i,i+m):
                if a[k][l]==b[k-i][l-i]:
                    sc+=1
        if sc==m*m:
            f=True
print("Yes" if f 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):
    flag = 0
    for j in range(m):
        if flag:
            break
        else:
            for k in range(m):
                if A[i + j][k] != B[j][k]:
                    flag = 1
                    break
                if A[j][i + k] != B[j][k]:
                    flag = 1
                    break

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

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(m):
    flag = 0
    for j in range(m):
        if flag:
            break
        else:
            for k in range(m):
                if A[i + j][i + k] != B[j][k]:
                    flag = 1
                    break

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = []
B = []
for i in range(N):
	a = list(input())
	A.append(a)
for j in range(M):
	b = list(input())
	B.append(b)
    
ans = "No"

for i in range(N-M+1):
	for j in range(N-M+1):
		c = 0
		for k in range(M):
			for l in range(M):
				if A[i+k][i+l] == B[k][l]:
					c+=1
		if c == M**2:
			ans = "Yes"
			break
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = []
B = []
for i in range(N):
	a = list(input())
	A.append(a)
for j in range(M):
	b = list(input())
	B.append(b)
#print(A,B)
print(A)
ans = "No"

for i in range(N-M+1):
	for j in range(N-M+1):
		c = 0
		for k in range(M):
			for l in range(M):
				if A[i+k][i+l] == B[k][l]:
					c+=1
		if c == M**2:
			ans = "Yes"
			break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

count = 0

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

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

for i in range(len(a_list)):
    for j in range(len(b_list)):
        if b_list[j] in a_list[i]:
            count += 1
        if count == m:
            print("Yes")
            sys.exit()

print("No")
sys.exit()

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

for i in range(n-m+1):
    for j in range(n-m+1):
        f = False
        for k in range(m):
            if a[i+k][j:j+m] != b[k]:
                f = True
                break
        if f:
            break
        else:
            print('Yes')
            exit()

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)]
f = False
for i in range(n):
    for j in range(n):
        if a[i][j] == b[0][0]:
            for k in range(m):
                for l in range(1, m):
                    if a[i+k][j+l] != b[k][l]:
                        f = True
                        break
                if f:
                    break
            print('Yes')
            exit()

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

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

print('No')

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 n in range(N-M+1):
    f_prev = -1
    for m in range(M):
        f = A[n+m].find(B[m])
        # print("n, m, f = %d, %d, %d"%(n, m, f))
        if f == -1 or (f_prev != f and m > 0):
            f = -1
            break
        else:
            f_prev = f
    if f != -1:
        break
if f != -1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
I=input;n,m=map(int,I().split());a=[I()for _ in[0]*n];b=[I()for _ in[0]*m];r=n-m+1;print('YNEOS'[sum(sum(b==[t[j:j+m]for t in a[i:i+m]]for j in range(r))for i in range(r))<1::2])

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[list(input())for i in range(n)]
t=[list(input())for i in range(m)]
c=0
for i in range(n-m):
    p=[]
    for j in range(m):
        s=a[i+j]
        p.append(s[i:i+m])
    else:
        if p==t:
            c=1
print("No"if c!=1else"Yes")