// Arup Guha
// 9/18/2013
// Solution to 2012 UCF HS Problem: Zombie

import java.util.*;
import java.io.*;

public class zombie {

	public static void main(String[] args) throws Exception {

		Scanner fin = new Scanner(new File("zombie.in"));
		int numCases = fin.nextInt();

		// Go through each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Read in dictionary.
			int n = fin.nextInt();
			word[] dictionary = new word[n];
			for (int i=0; i<n; i++)
				dictionary[i] = new word(fin.next());

			// So output is in correct order.
			Arrays.sort(dictionary);

			// Case header.
			System.out.println("Scenario #"+loop+":");

			// Do each word...
			int numZombie = fin.nextInt();
			for (int i=0; i<numZombie; i++) {

				word zombieWord = new word(fin.next());
				ArrayList<String> ans = getMatches(dictionary, zombieWord);

				// Output the results.
				if (ans.size() > 0) {
					System.out.println("Did you mean:");
					for (int j=0; j<ans.size(); j++)
						System.out.println(ans.get(j)+"?");
				}

				// No results :(
				else {
					System.out.println("No matches found.");
				}

				System.out.println();
			}
		}

		fin.close();
	}

	public static ArrayList<String> getMatches(word[] dictionary, word zombieWord) {

		ArrayList<String> ans = new ArrayList<String>();

		// Go through each, seeing if it's a match.
		for (int i=0; i<dictionary.length; i++)
			if (zombieWord.equals(dictionary[i]))
				ans.add(dictionary[i].str);

		return ans;
	}
}

class word implements Comparable<word> {

	public String str;
	public int[] freq;

	public word(String s) {
		str = s;
		freq = getFreq();
	}

	// Just do string compare!
	public int compareTo(word other) {
		return this.str.compareTo(other.str);
	}

	// Returns the number of runs of each letter.
	public int[] getFreq() {

		int[] ans = new int[26];

		// Initial values.
		char curLetter = str.charAt(0);
		ans[curLetter-'A']++;

		// Go through the rest.
		for (int i=1; i<str.length(); i++) {

			// New run, so mark it.
			if (str.charAt(i) != curLetter) {
				curLetter = str.charAt(i);
				ans[curLetter-'A']++;
			}
		}

		return ans;
	}

	public boolean equals(word other) {

		// Look for any mismatch.
		for (int i=0; i<26; i++)
			if (this.freq[i] != other.freq[i])
				return false;

		// None found.
		return true;
	}
}