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:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,M = inputMap()
    A = []
    for i in range(N):
        tmp = input()
        A.append(tmp)
        
    B = []
    for i in range(M):
        tmp = input()
        B.append(tmp)
        
    if N < M:
        print("No")
        sys.exit()
        
    if N == M:
        tmp1 = "".join(A)
        tmp2 = "".join(B)
        
        if tmp1 == tmp2:
            print("Yes")
        else:
            print("No")
        sys,exit()
        
    points = []
    for i,val in enumerate(A):
        tmp = run(val, B[0])
        if tmp != -1 and N-i >= M:
            points.append((i,tmp))
            tmp = run(val[tmp+1:], B[0])
            if tmp != -1 and N-i >= M:
                points.append((i,tmp))
            
    for i in points:
        lines, point = i
        flg = True
        for j,val in enumerate(B):
            tmp = A[lines+j].find(val)
            if tmp == -1:
                flg = False
        
        if flg == True:
            print("Yes")
            sys.exit()
            
    print("No")
    
def run(ss, dd):
    return ss.find(dd)
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,M = inputMap()
    A = []
    for i in range(N):
        tmp = input()
        A.append(tmp)
        
    B = []
    for i in range(M):
        tmp = input()
        B.append(tmp)
        
    if N < M:
        print("No")
        sys.exit()
        
    points = []
    for i,val in enumerate(A):
        tmp = run(val, B[0])
        if tmp != -1 and N-i >= M:
            points.append((i,tmp))
            tmp = run(val[tmp+1:], B[0])
            if tmp != -1 and N-i >= M:
                points.append((i,tmp))
            
    for i in points:
        lines, point = i
        flg = True
        for j,val in enumerate(B):
            tmp = A[lines+j].find(val)
            if tmp == -1:
                flg = False
        
        if flg == True:
            print("Yes")
            sys.exit()
            
    print("No")
    
def run(ss, dd):
    return ss.find(dd)
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,M = inputMap()
    A = []
    for i in range(N):
        tmp = input()
        A.append(tmp)
        
    B = []
    for i in range(M):
        tmp = input()
        B.append(tmp)
        
    if N < M:
        print("No")
        sys.exit()
        
    points = []
    for i,val in enumerate(A):
        tmp = val.find(B[0])
        if tmp != -1 and N-i >= M:
            points.append((i,tmp))
            
    for i in points:
        lines, point = i
        flg = True
        for j,val in enumerate(B):
            tmp = A[lines+j].find(val)
            if tmp == -1:
                flg = False
        
        if flg == True:
            print("Yes")
            sys.exit()
            
    print("No")
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m=map(int,input().split())
a=np.zeros([n,n])
b=np.zeros([m,m])
map_ = {".":1,"#":-1}

for i in range(n):
  temp = list(input())
  temp = [map_[c] for c in temp]
  a[i,:] = np.array(temp)
  
for i in range(m):
  temp = list(input())
  temp = [map_[c] for c in temp]
  b[i,:] = np.array(temp)

flag=False
for i in range(n-m+1):
  for j in range(n-m+1):
    temp_a = a[i:i+m,j:j+m]
    print(temp_a)
    check=np.sum(temp_a*b,axis=1)
    check=np.sum(check,axis=0)
    print(check)
    if check==m*m:
      flag=True
      break
    else:
      pass
if flag:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m=map(int,input().split())
a=np.zeros([n,n])
b=np.zeros([m,m])
map_ = {".":1,"#":-1}

for i in range(n):
  temp = list(input())
  temp = [map_[c] for c in temp]
  a[i,:] = np.array(temp)
  
for i in range(m):
  temp = list(input())
  temp = [map_[c] for c in temp]
  b[i,:] = np.array(temp)

check=0
for i in range(n-m+1):
  for j in range(n-m+1):
    temp_a = a[i:i+m,j:j+m]
    check=np.sum(temp_a*b,axis=1)
    check=np.sum(check,axis=0)
    if check==m*m:
      break
    else:
      pass
if check==m*m:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m=map(int,input().split())
a=np.zeros([n,n])
b=np.zeros([m,m])
map_ = {".":1,"#":-1}

for i in range(n):
  temp = list(input())
  temp = [map_[c] for c in temp]
  a[i,:] = np.array(temp)
  
for i in range(m):
  temp = list(input())
  temp = [map_[c] for c in temp]
  b[i,:] = np.array(temp)

check=0
for i in range(n-m):
  for j in range(n-m):
    temp_a = a[i:i+m,j:j+m]
    check=np.sum(temp_a*b,axis=1)
    check=np.sum(check,axis=0)
    if check==m*m:
      break
    else:
      pass
if check==m*m:
  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())

diff = n - m
if diff == 0:
    if a == b:
        print('Yes')
    else:
        print('No')
else:
    for i in range(diff + 1):
        ans = True
        for j in range(m):
            for k in range(m):
                if b[j][k] != a[j + i][k + i]:
                    ans = False
                # print(i, j, k)
        if ans:
            print('Yes')
            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())

diff = n - m
if diff == 0:
    if a == b:
        print('Yes')
    else:
        print('No')
else:
    for i in range(diff + 1):
        ans = True
        for j in range(m):
            for k in range(m):
                if b[j][k] != a[j + 1][k + 1]:
                    ans = False
        if ans:
            print('Yes')
            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())

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

for i in range(N-M+1):
    for j in range(N-M+1):
        count=0
        for k in range(M):
            for l in range(M):
                if a[i][j]!=b[k][l]:
                    break
                else:
                    count+=1
        if count==M*M:
            print("Yes")
            exit()
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)]

for i in range(N-M+1): # 何行目か
    for j in range(N-M+1):
        count=0
        for k in range(M):
            for l in range(M):
                if a[i][j]==b[k][l]:
                    count+=1
        if count==M*M:
            print("Yes")
            exit()
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)]

def main():

    for i in range(n-m+1):
        for j in range(n-m+1):
            if match(i, j):
                print("yes")
                exit()
    
    print("no")

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#ABC054b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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


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


for i in range(n - m):
    for j in range(n - m):
        if (a[i][j] == b[0][0] and match(i, j)):
            print("Yes")
            exit(0)
print("No")

Submission status: Wrong Answer

Solution code:
import sys
# (x,y) 探索開始座標を与えると、それで画像が一致していればTrue,そうでなければ　Falseを返す関数hantei
def hantei(x,y):
    for h in range(m):
        if A[h][x:x+m]!=B[h]:
            return False
    else:
        return True
            
n,m =map(int,input().split())
A=[]
B=[]
for i in range(n):
    A.append(input())
for j in range(m):
    B.append(input())    
X=[0,0] #最初の探索開始座標
for y in range(n-m):
    for x in range(n-m):
        if hantei(x,y):
            print("Yes")
            sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
import sys
# (x,y) 探索開始座標を与えると、それで画像が一致していればTrue,そうでなければ　Falseを返す関数hantei
def hantei(x,y):
    for h in range(m):
        if A[h][x:x+m]!=B[h]:
            return False
    else:
        return True
            
n,m =map(int,input().split())
A=[]
B=[]
for i in range(n):
    A.append(input())
for j in range(m):
    B.append(input())    
X=[1,1] #最初の探索開始座標
for y in range(n-m):
    for x in range(n-m):
        if hantei(x,y):
            print("Yes")
            sys.exit()
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)]
ans = 'Yes'
def match(i, j):
  for k in range(M):
    for l in range(M):
      if A[i+k][j+l] != B[k][l]:
        return False
  return True
for i in range(N-M+1):
  for j in range(N-M+1):
    if not match(i, j):
      ans = 'No'
      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 = 'Yes'
def match(i, j):
  for k in range(M):
    for l in range(M):
      if A[i+k][j+l] != B[k][l]:
        return False
  return True
for i in range(N-M):
  for j in range(N-M):
    if not match(i, j):
      ans = 'No'
      break
print(ans)

Submission status: Wrong Answer

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

for i in range(N):
  a[i].extend(list(str(input())))
for j in range(M):
  b[j].extend(list(str(input())))
tmp_val=0
new_list=[[]*M for _ in range(N*(N-M+1))]
n=0
for val in range(N):
  n=n
  for val2 in range(N-M+1):
    new_list[n].extend(a[val][val2:val2+M])
    n+=1
for i in range(M):
  if (b[i] in new_list)==True:
    tmp_val+=1
  else:
    pass
if tmp_val==M:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

for i in range(N):
  a[i].extend(list(str(input())))
for j in range(M):
  b[j].extend(list(str(input())))
tmp_val=0
new_list=[[]*M for _ in range(N*(N-M+1))]
for val in range(N):
  for val2 in range(N-M+1):
  	new_list[val*val2].extend(a[val][val2:val2+M])
for i in range(M):
  if (b[i] in new_list)==True:
    tmp_val+=1
  else:
    pass
if tmp_val==M:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

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

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

flag=False
for i in range(n-m+1):
    if not flag:
        check=[]
        for j in range(m):
            if b[j] in a[i+j]:
                check.append(1)
        if sum(check)==m:
            flag=True

print('Yes' if flag 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())

ans = "No"
for x in range(0,n-m+1):
    for y in range(0,n-m+1):
        bina = True
        for i in range(m):
            for j in range(m):
                if a[x+i][x+j] != b[i][j]:
                    bina = False
        if bina:
            ans = "Yes"

print(ans)

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

ans = "No"
for x in range(0,n-m):
    for y in range(0,n-m):
        bina = True
        for i in range(m):
            for j in range(m):
                if a[x+i][x+j] != b[i][j]:
                    bina = False
        if bina:
            ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
  N, M = map(int,input().split())
  A = []
  B = []
  
  for i in range(N):
    A.append(input())
  for i in range(M):
    B.append(input())
    
  for i in range(N-M+1):
    for j in range(N-M+1):
      for k in range(M):
        s1 = A[i+k][j:j+M]
        s2 = B[k]
        if s1 != s2:
          break
        else:
          print("Yes")
          return None
  print("No")
  
if __name__ == "__main__":
  solve()

Submission status: Wrong Answer

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

A = [None]*N
for i in range(N):
    A[i] = input()

B = [None]*M
for i in range(M):
    B[i] = input()

def check():

    for x in range(N-M+1):
        for y in range(N-M+1):
            for r in range(M):
                if all(A[r+x][c+y] == B[r][c] for c in range(M)):
                    return "Yes"
                else:
                    break
    return "No"
print(check())

Submission status: Wrong Answer

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

A = [None]*N
for i in range(N):
    A[i] = input()

B = [None]*M
for i in range(M):
    B[i] = input()

def check():

    for x in range(N-M+1):
        for y in range(N-M+1):
            for r in range(M):
                if all(A[r+x][c+y] == B[r][c] for c in range(M)):
                    return "Yes"
    return "No"
print(check())

Submission status: Wrong Answer

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

A = [None]*N
for i in range(N):
    A[i] = input()

B = [None]*M
for i in range(M):
    B[i] = input()

def check():
    for x in range(N-M+1):
        for y in range(N-M+1):
            for r in range(M):
                if all(A[r+x][c+y] == B[r][c] for c in range(M)):
                    return "Yes"
    return "No"
print(check())

Submission status: Wrong Answer

Solution code:
import sys
N, M = map(int, input().split())
aLst = list(input() for i in range(N))
bLst = list(input() for i in range(M))
ans = False
cnt = 0
for j in range(N - M):
    for k in range(N - M + 1):
        if aLst[j][k:k + M] == bLst[0]:
            cnt += 1
            for l in range(1, M):
                if aLst[j + l][k:k + M] == bLst[l]:
                    cnt += 1
                else:
                    break

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

print('No')

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
aLst = list(input() for i in range(N))
bLst = list(input() for i in range(M))
ans = False

for i in range(M - 1):
    for j in range(N - 1):
        for k in range(N - M + 1):
            if aLst[j][k:k + M] == bLst[i]:
                if aLst[j + 1][k:k + M] == bLst[i + 1]:
                    ans = True

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
aLst = list(input() for i in range(N))
bLst = list(input() for i in range(M))
cnt = 0
for i in range(M):
    for j in range(N):
        if aLst[j].count(bLst[i]) >= 1:
            cnt += 1
            break

if cnt == M:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
aLst = list(input() for i in range(N))
bLst = list(input() for i in range(M))
cnt = 0
for i in range(M):
    for j in range(N):
        if aLst[j].count(bLst[i]):
            cnt += 1
            break

if cnt == M:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [list(input()) for x in range(n)]
for i in range(m):
    target = list(input())
    if any(target[j] == a[i][j] for j in range(m)):
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [list(input()) for x in range(n)]
for i in range(m):
    target = list(input())
    if any(target[j] == a[i][j] for j in range(len(target))):
        print("Yes")
        exit()
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())
ii=0
jj=0
cnt=0
for i in range(n-m+1):
	for j in range(n-m+1):
		while cnt<m**2:
			if b[ii][jj]==a[i][j]:
				if jj==m-1:
					jj=0
					ii+=1
				else:
					jj+=1
				cnt+=1
			else:
				break
		if cnt==m**2:
			print("Yes")
			exit()
print("No")

Submission status: Wrong Answer

Solution code:
# ABC 54, B - template matching
n, m = [int(el) for el in input().split(' ')]
A = [list(input()) for i in range(n)]
B = [list(input()) for i in range(m)]

def compute():
    for i in range(n-m):
        for j in range(n-m):
            sub_A = [a[j:j+m] for a in A[i:i+m]]
            if sub_A == B:
                return('Yes')
    else:
        return('No')

print(compute())

Submission status: Wrong Answer

Solution code:
n,m = list(map(int,input().split()))
import numpy as np
A = np.zeros([n,n]).astype(np.int)
B = np.zeros([m,m]).astype(np.int)
for i in range(n):
    A[i,:] = [1 if s == '#' else 0 for s in input()]
for i in range(m):
    B[i,:] = [1 if s == '#' else 0 for s in input()]
print(A)
print("---")
print(B)
print("---")

ans = 0
for i in range(0,n-m+1):
    for j in range(0,n-m+1):
        if (A[i:i+m,j:j+m] == B).all():
            ans = 1
            break

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

Submission status: Wrong Answer

Solution code:
import sys

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

    print('No')

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

imb = []
for _ in range(m):
    imb.append(input())

for i in range(n-m+1):
    for j in range(n-m+1):
        flag = False
        for k in range(m):
            if ima[i+k][j:j+m] == imb[k]:
                flag = True
            else:
                break
        if flag:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, M: int, A: "List[str]", B: "List[str]"):
    f = False
    for i in range(N-M):
        for j in range(N-M):
            flag = True
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] != B[k][l]:
                        flag = False
            if flag:
                f = True
    if f:
        print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    B = [ next(tokens) for _ in range(M) ]  # type: "List[str]"
    solve(N, M, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, M: int, A: "List[str]", B: "List[str]"):
    f = False
    for i in range(N-M+1):
        for j in range(N-M+1):
            flag = True
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] != B[k][l]:
                        flag = False
            if flag:
                f = True
    if flag:
        print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    B = [ next(tokens) for _ in range(M) ]  # type: "List[str]"
    solve(N, M, A, B)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ann = [str(input()) for i in range(n)]
bmm = [str(input()) for i in range(m)]
for y in range (n-m+1):
    for x in range(n-m+1):
        flag = True
        for i in range(m):
            if bmm[i] != ann[y+i][x:x+m]:
                flag = False
        if flag == True:
            break
if flag == True:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# ABC 054 B

import sys

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

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

ret = [[] for i in range(M)]

for i in range(len(B)):
    for j in range(len(A)):
        f = -1
        while True:
            f = A[j].find(B[i], f+1)
            if f == -1:
                break

            ret[i].append((j, f))

flag = False

# ret = [[(1, 1)],
#        [(1, 1), (2, 1)]]

if M == 1 and len(ret[0]) > 0:
    print('Yes')
    sys.exit(0)

for i in range(len(ret[0])):
    start = ret[0][i] # (x, y)

    for j in range(M-1):
        if not (start[0]+1, start[1]) in ret[j+1]:
            break
        if j == M-2:
            print('Yes')
            sys.exit(0)

print('No')

Submission status: Wrong Answer

Solution code:
# ABC 054 B

import sys

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

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

ret = [[] for i in range(M)]

for i in range(len(B)):
    for j in range(len(A)):
        f = -1
        while True:
            f = A[j].find(B[i], f+1)
            if f == -1:
                break

            ret[i].append((j, f))

flag = False

# ret = [[(1, 1)],
#        [(1, 1), (2, 1)]]

if M == 1 and len(ret[0]) > 0:
    print('True')
    sys.exit(0)

for i in range(len(ret[0])):
    start = ret[0][i] # (x, y)

    for j in range(M-1):
        if not (start[0]+1, start[1]) in ret[j+1]:
            break
        if j == M-2:
            print('Yes')
            sys.exit(0)

print('No')

Submission status: Wrong Answer

Solution code:
# ABC 054 B

import sys

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

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

ret = [[] for i in range(M)]

for i in range(len(B)):
    for j in range(len(A)):
        f = -1
        while True:
            f = A[j].find(B[i], f+1)
            if f == -1:
                break

            ret[i].append((j, f))

flag = False

flag = True

for i in range(len(ret[0])):
    start = ret[0][i] # (x, y)

    for j in range(M-1):
        if not (start[0]+1, start[1]) in ret[j+1]:
            flag = False
            break
        if j == M-2:
            print('Yes')
            sys.exit(0)

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

Submission status: Wrong Answer

Solution code:
# ABC 054 B

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

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

ret = [[] for i in range(M)]

for i in range(len(B)):
    for j in range(len(A)):
        f = 0
        while True:
            f = A[j].find(B[i], f+1)
            if f == -1:
                break

            ret[i].append((j, f))

flag = False

# ret = [[(1, 1)],
#        [(1, 1), (2, 1)]]

for i in range(len(ret[0])):
    start = ret[0][i] # (x, y)
    for j in range(M-1):
        if not (start[0]+1, start[1]) in ret[j+1]:
            break
        if j == M-2:
            flag = True

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

Submission status: Wrong Answer

Solution code:
def solve(n, m, a, b):
  for i in range(n - m + 1):
    for j in range(n - m + 1):
      if a[i:i+m][j:j+m] == b:
        return True
  return False
  

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
print('Yes' if solve(n, m, a, b) else '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] = list(input())
for i in range(m):
    B[i] = list(input())

check = 0


for k in range(n-m):
    if check == m:
        break
    C = A[k:k+m]
    for i in range(n-m):
        if check == m:
            break
        check = 0
        for j in range(m): 
            if C[j][i:i+m] == B[j]:
                check += 1   
            if check == m:
                print('Yes')  
         


if check != m:
    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] = list(input())
for i in range(m):
    B[i] = list(input())

check = 0


for k in range(n-m):
    if check == m:
        break
    C = A[k:k+m]
    for i in range(n-m):
        if check == m:
            break
        check = 0
        for j in range(m): 
            if C[j][i:i+m] == B[j]:
                check += 1     
         


if check == m:
    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] = list(input())
for i in range(m):
    B[i] = list(input())

check = 0


for k in range(n-m+1):
    C = A[k:k+m]
    for i in range(n-m+1):
        check = 0
        for j in range(m): 
            if C[j][i:i+m] == B[j]:
                check += 1        


if check == m:
    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] = list(input())
for i in range(m):
    B[i] = list(input())

check = 0


for i in range(n-m+1):
    C = A[i:i+m]

for i in range(n-m+1):
    check = 0
    for j in range(m): 
        if C[j][i:i+m] == B[j]:
            check += 1        


if check == m:
    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] = list(input())
for i in range(m):
    B[i] = list(input())

check = 0


for i in range(n-m+1):
    C = A[i:i+m]

for i in range(n-m+1):
    for j in range(m): 
        if C[j][i:i+m] == B[j]:
            check = 1


if check == 1:
    print('Yes')
else:
    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(m):
    if b[i] in a[i][:len(b[i])]:
        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(m):
    if b[i] in a[i][:len(b[i])]:
        print("Yes")
        exit()
print("No")
print(a[0][:len(b)])

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(m):
    if b[i] in a[i][:len(b)]:
        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(m):
    if b[i] in a[i]:
        print("Yes")
        exit()
print("No")