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

A = [eval(input()) for _ in range(N)]

B = [eval(input()) for _ in range(M)]



cnt = 0

tmp = []

for a in A:

  for b in B:

    if(tmp != B):

      if(b in a):

        tmp.append(b)

    else:

      break

if(tmp == B):

  print("Yes")

else:

  print("No")

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

A = [eval(input()) for _ in range(N)]

B = [eval(input()) for _ in range(M)]



tmp = []

for a in A:

  for b in B:

    if(tmp != B):

      if(b in a):

        tmp.append(b)

    else:

      break

if(tmp == B):

  print('Yes')

else:

  print('No')
N, M = list(map(int, input().split()))
A = [eval(input()) for _ in range(N)]
B = [eval(input()) for _ in range(M)]
cnt = 0
tmp = []
for a in A:
    for b in B:
        if tmp != B:
            if b in a:
                tmp.append(b)
        else:
            break
if tmp == B:
    print("Yes")
else:
    print("No")

N, M = list(map(int, input().split()))
A = [eval(input()) for _ in range(N)]
B = [eval(input()) for _ in range(M)]
tmp = []
for a in A:
    for b in B:
        if tmp != B:
            if b in a:
                tmp.append(b)
        else:
            break
if tmp == B:
    print("Yes")
else:
    print("No")

-cnt = 0