{$APPTYPE CONSOLE}
Uses
  SysUtils, Math;
var
  a : array [1..200] of string;
  n, m, k, i, j, x, y : longint;
  s : string;
  found : boolean;

Begin
  reset(Input, 'words.in');
  rewrite(Output, 'words.out');
  readln(n, m);
  for i := 1 to n do
    readln(a[i]);
  readln(k);
  for x := 1 to k do begin
    readln(s);
    found := false;
    for y := 1 to n do
      for i := 1 to length(a[y]) do begin
       j := 0;
       while (i + j <= length(a[y])) and (j < length(s)) and (a[y][i + j] = s[j + 1]) do
         inc(j);
       if (j = length(s)) then
         found := true;
      end;
    for y := 1 to m do
      for i := 1 to n do begin
         j := 0;
         while (i + j <= n) and (j < length(s)) and (a[i + j][y] = s[j + 1]) do
           inc(j);
         if (j = length(s)) then
           found := true;
      end;
    if (found) then
      writeln('YES')
    else
      writeln('NO');
  end;
  close(Input);
  close(Output);
End.