#atcoderABC054B. Template Matching

Template Matching

Problem Statement

You are given an image AA composed of NN rows and NN columns of pixels, and a template image BB composed of MM rows and MM columns of pixels.
A pixel is the smallest element of an image, and in this problem it is a square of size 1×11×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 AA is given as NN strings A1,...,ANA_1,...,A_N.
The jj-th character in the string AiA_i corresponds to the pixel at the ii-th row and jj-th column of the image AA (1i,jN)(1≦i,j≦N).
Similarly, the template image BB is given as MM strings B1,...,BMB_1,...,B_M.
The jj-th character in the string BiB_i corresponds to the pixel at the ii-th row and jj-th column of the template image BB (1i,jM)(1≦i,j≦M).

Determine whether the template image BB is contained in the image AA when only parallel shifts can be applied to the images.

Constraints

  • 1MN501≦M≦N≦50
  • AiA_i is a string of length NN consisting of # and ..
  • BiB_i is a string of length MM consisting of # and ..

Input

The input is given from Standard Input in the following format:

NN MM A1A_1 A2A_2 ::
ANA_N B1B_1 B2B_2 ::
BMB_M

Output

Print Yes if the template image BB is contained in the image AA. Print No otherwise.

Input 1

3 2
#.#
.#.
#.#
#.
.#

Output 1

Yes

The template image BB is identical to the upper-left 2×22 × 2 subimage and the lower-right 2×22 × 2 subimage of AA. Thus, the output should be Yes.

Input 2

4 1
....
....
....
....
#

Output 2

No

The template image BB, composed of a black pixel, is not contained in the image AA composed of white pixels.