Uses
  SysUtils, Math;
var
  a : array [1..200] of string;
  p : array [1..200] of longint;
  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;
    j := 0;
    for i := 2 to length(s) do begin
      while (j > 0) and (s[i] <> s[j + 1]) do
        j := p[j];
      if (s[i] = s[j + 1]) then
        inc(j);
      p[i] := j;
    end;
    for y := 1 to n do begin
      j := 0;
      for i := 1 to length(a[y]) do begin
        while (j > 0) and (a[y][i] <> s[j + 1]) do
          j := p[j];
        if (a[y][i] = s[j + 1]) then
          inc(j);
        if (j >= length(s)) then
          found := true;
      end;
    end;
    for y := 1 to m do begin
      j := 0;
      for i := 1 to n do begin
        while (j > 0) and (a[i][y] <> s[j + 1]) do
          j := p[j];
        if (a[i][y] = s[j + 1]) then
          inc(j);
        if (j >= length(s)) then
          found := true;
      end;
    end;
    if (found) then
      writeln('YES')
    else
      writeln('NO');
  end;
  close(Input);
  close(Output);
End.