<gh_stars>0
#!/bin/python3

import math
import os
import random
import re
import sys

#
# Complete the 'gridSearch' function below.
#
# The function is expected to return a STRING.
# The function accepts following parameters:
#  1. STRING_ARRAY G
#  2. STRING_ARRAY P
#

def gridSearch(G, P):
    # Write your code here
    for i, v in enumerate(G):
        #We can have more than 1 substring :-)
        for s in ((m.start(0)) for m in re.finditer("(?=%s)"%P[0],v)):
            for j in range(1, len(P)):
                if G[i+j][s:s+len(P[0])] != P[j]:
                    break
            else:
                return 'YES'
                    
    return 'NO'
          
                    
      
if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    t = int(input().strip())

    for t_itr in range(t):
        first_multiple_input = input().rstrip().split()

        R = int(first_multiple_input[0])

        C = int(first_multiple_input[1])

        G = []

        for _ in range(R):
            G_item = input()
            G.append(G_item)

        second_multiple_input = input().rstrip().split()

        r = int(second_multiple_input[0])

        c = int(second_multiple_input[1])

        P = []

        for _ in range(r):
            P_item = input()
            P.append(P_item)

        result = gridSearch(G, P)

        fptr.write(result + '\n')

    fptr.close()

#!/bin/python3

import math
import os
import random
import re
import sys

#
# Complete the 'gridSearch' function below.
#
# The function is expected to return a STRING.
# The function accepts following parameters:
#  1. STRING_ARRAY G
#  2. STRING_ARRAY P
#

def gridSearch(G, P):
    # Write your code here
    for i, v in enumerate(G):
        #We can have more than 1 substring :-)
        for s in ((m.start(0)) for m in re.finditer("(?=%s)"%P[0],v)):
            for j in range(1, len(P)):
                if G[i+j][s:s+len(P[0])] != P[j]:
                    break
            else:
                return 'YES'
                    
    return 'NO'
          
                    
      
if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    t = int(input().strip())

    for t_itr in range(t):
        first_multiple_input = input().rstrip().split()

        R = int(first_multiple_input[0])

        C = int(first_multiple_input[1])

        G = []

        for _ in range(R):
            G_item = input()
            G.append(G_item)

        second_multiple_input = input().rstrip().split()

        r = int(second_multiple_input[0])

        c = int(second_multiple_input[1])

        P = []

        for _ in range(r):
            P_item = input()
            P.append(P_item)

        result = gridSearch(G, P)

        fptr.write(result + '\n')

    fptr.close()
#!/bin/python3 # # Complete the 'gridSearch' function below. # # The function is expected to return a STRING. # The function accepts following parameters: #  1. STRING_ARRAY G #  2. STRING_ARRAY P # # Write your code here #We can have more than 1 substring :-)