import java.io.*;
import java.math.*;
import java.util.*;

public class words_ab implements Runnable {

//Main part
	
	int MAX_N = 50;
	int MAX_M = 50;
	int MAX_K = 50;
	int MAX_LEN = 50;
	
	void solve() throws IOException {
		int n = nextInt();
		myAssert(1 <= n && n <= MAX_N, "n out of bounds exception");
		int m = nextInt();
		myAssert(1 <= m && m <= MAX_M, "m out of bounds exception");
		String[] tab = new String[n];
		String[] rtab = new String[m];
		for (int i = 0; i < n; ++i) { 
			tab[i] = br.readLine();
			myAssert(tab[i].length() == m, "Wrong line length, line #" + (i + 2));
			checkString(tab[i], "tab[" + i + "]");
		}
		for (int i = 0; i < m; ++i) {
			rtab[i] = "";
			for (int j = 0; j < n; ++j) {
				rtab[i] += tab[j].charAt(i);
			}
		}
		
		int k = nextInt();
		myAssert(1 <= k && k <= MAX_K, "k out of bounds exception");
		
		loop:
		for (int i = 0; i < k; ++i) {
			String s = br.readLine();
			myAssert(1 <= s.length() && s.length() <= MAX_LEN, "s.length() out of bounds exception");
			checkString(s, "word#" + i);
			for (int j = 0; j < n; ++j) {
				if (tab[j].indexOf(s) >= 0) {
					out.println("YES");
					continue loop;
				}
			}
			for (int j = 0; j < m; ++j) {
				if (rtab[j].indexOf(s) >= 0) {
					out.println("YES");
					continue loop;
				}
			}
			out.println("NO");
		}
	}

	void checkString(String s, String name) {
		for (int i = 0; i < s.length(); ++i) {
			myAssert('a' <= s.charAt(i) && s.charAt(i) <= 'z', name + ".charAt(" + i +") out of bounds exception");
		}
	}
	
	
//Template
	
	public static void main(String[] args) {
		new Thread(new words_ab()).start();
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;

	public void run() {
		try {
			br = new BufferedReader(new FileReader("words.in"));
			out = new PrintWriter("words.out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	String nextToken() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new Error("Enexpected end of file");
			}
		}
		return st.nextToken();
	}

	void myAssert(boolean e, String msg) {
		if (!e) {
			throw new Error(msg);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}	
}
