Problem:
Score : 200 points

Problem Statement

You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.

A pixel is the smallest element of an image, and in this problem it is a square of size 1×1.

Also, the given images are binary images, and the color of each pixel is either white or black.

In the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.

The image A is given as N strings A_1,...,A_N.

The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).

Similarly, the template image B is given as M strings B_1,...,B_M.

The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).

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

Constraints

1≦M≦N≦50

A_i is a string of length N consisting of # and ..

B_i is a string of length M consisting of # and ..

Input

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

N M
A_1
A_2
:
A_N
B_1
B_2
:
B_M

Output

Print Yes if the template image B is contained in the image A. Print No otherwise.

Sample Input 1

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

Sample Output 1

Yes

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

Sample Input 2

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

Sample Output 2

No

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

Solution in C# (.NET Core 3.1.201) (judge verdict: Runtime Error)

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace Green
{
    using static Ex;
    public class Solve
    {
        public static void Main(string[] args)
        {
            new abc054_b();
        }
    }
    public class abc054_b
    {
        int n, m, alen, blen;
        string[] a, b;
        public abc054_b()
        {
            (n, m) = ReadIntArray().ToTpl2();
            a = new string[n];
            b = new string[m];
            for (int i = 0; i < n; i++)
                a[i] = Read;
            for (int i = 0; i < m; i++)
                b[i] = Read;

            alen = a[0].Length;
            blen = b[0].Length;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < (alen - blen + 1); j++)
                {
                    if (a[i][j] == b[0][0] && issame(i, j))
                    {
                        "Yes".Cw();
                        return;
                    }
                }
            }
            "No".Cw();
        }

        bool issame(int i, int j)
        {
            for (int bi = 0; bi < m; bi++)
            {
                for (int bj = 0; bj < blen; bj++)
                {
                    if (a[i + bi][j + bj] != b[bi][bj])
                        return false;
                }
            }
            return true;
        }
    }
    public class agc017_a
    {
        int n, p;
        /// <summary>
        /// p==0
        /// %2==1.count==%2==0
        ///
        /// p==1
        /// %2==1.count==%2==1
        /// </summary>
        public agc017_a()
        {
            (n, p) = ReadIntArray().ToTpl2();
            var a = ReadIntArray();
            long ans = 0;

            for (int x = 0; x < 1 << n; x++)
            {
                var cou = 0;
                for (int j = 0; j < n; j++)
                {
                    if (a[j] % 2 == 1 && (x >> j & 1) == 1)
                        cou++;
                }
                if (cou % 2 == p) ans++;
            }
            ans.Cw();
        }
    }
    public class abc048_b
    {
        long a, b, x;
        public abc048_b()
        {
            (a, b, x) = ReadLongArray().ToTpl3();
            if (a == 0)
                (b / x + 1).Cw();
            else
                (b / x - (a - 1) / x).Cw();
        }
    }
    public class sumitb2019_d
    {
        public sumitb2019_d()
        {
            var n = ReadInt;
            var s = Read.Select(v => v - '0').ToArray();


            var num = s[0];
            var set = new HashSet<(int, int, int)>();
            set.Add((num, -1, -1));

            for (int i = 1; i < n; i++)
            {
                num = s[i];

                var next = new HashSet<(int, int, int)>();
                next.Add((num, -1, -1));

                foreach (var v in set)
                {
                    if (v.Item3 != -1)
                    {
                        next.Add(v);
                        continue;
                    }

                    if (v.Item2 == -1)
                        next.Add((v.Item1, num, -1));
                    else
                        next.Add((v.Item1, v.Item2, num));
                }
                set = next;

                for (int j = 0; j < 10; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {

                    }
                }
            }
        }
    }
    public class abc148_e
    {
        long res = 0;
        public abc148_e()
        {
            var n = ReadLong;
            f(n);
            res.Cw();
        }

        long f(long n)
        {
            if (n < 2)
            {
                return 1;
            }

            int c = 0;
            var tmp = f(n - 2);
            if (tmp == 0)
            {
                res = 1;
                return 0;
            }

            var s = tmp.ToString();
            for (int i = s.Length - 1; i >= 0; i--)
            {
                if (s[i] != '0') break;

                c++;
            }

            if (c == 0) return n * tmp;

            res += c;
            return n * tmp / (10 * c);
        }
    }
    public class abc_
    {
        public abc_()
        {
        }
    }

    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }



        public static bool Mins<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
        public static bool Maxs<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
        public static void Swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
        public static void Swap<T>(List<T> list, int i, int j) { T tmp = list[j]; list[j] = list[i]; list[i] = tmp; }

        public static long Lcm(int x, int y) { return x / Gcd(x, y) * y; }
        public static long Gcd(long m, long n) { if (n == 0) return m; return Gcd(n, m % n); }
        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
        public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
        public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var v = new string[N]; for (long i = 0; i < N; ++i) v[i] = Read; return v; }
        public static int[] ReadIntArray(long N) { var v = new int[N]; for (long i = 0; i < N; ++i) v[i] = ReadInt; return v; }
        public static long[] ReadLongArray(long N) { var v = new long[N]; for (long i = 0; i < N; ++i) v[i] = ReadLong; return v; }

        public static (T, T) ToTpl2<T>(this T[] v) { return (v[0], v[1]); }
        public static (T, T, T) ToTpl3<T>(this T[] v) { return (v[0], v[1], v[2]); }
        public static (T, T, T, T) ToTpl4<T>(this T[] v) { return (v[0], v[1], v[2], v[3]); }
        public static (T, T, T, T, T) ToTpl5<T>(this T[] v) { return (v[0], v[1], v[2], v[3], v[4]); }


        public static int LowerBound<T>(T[] a, T v)
        {
            return LowerBound(a, v, Comparer<T>.Default);
        }

        public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res == -1) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }

        /// <summary>
        /// lower_boundは、探索したいkey以上のイテレータを返す
        /// upper_boundは、探索したいkeyより大きいイテレータを返す
        public static int UpperBound<T>(List<T> a, T v)
        {
            return UpperBound(a, v, Comparer<T>.Default);
        }

        public static int UpperBound<T>(List<T> a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Count - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res <= 0) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }
    }
}