// Arup Guha
// 7/18/2012
// Solution to BHCSI Contest Problem: Word

import java.util.*;
import java.io.*;

public class word {

	public static final int MATCH = 100;

	public static void main(String[] args) throws Exception {

		Scanner fin = new Scanner(new File("word.in"));

		int numCases = fin.nextInt();

		for (int loop=1; loop<=numCases; loop++) {

			int r = fin.nextInt();
			int c = fin.nextInt();
			int numWords = fin.nextInt();

			// Read in grid.
			char[][] grid = new char[r][c];
			for (int i=0; i<r; i++) {
				String temp = fin.next();
				for (int j=0; j<temp.length(); j++)
					grid[i][j] = temp.charAt(j);
			}

			// Just sum up the score for each word.
			int score = 0;
			for (int i=0; i<numWords; i++) {
				String search = fin.next();
				score += getScore(grid, search);
			}

			System.out.println("Maximum Score for Word Search #"+loop+": "+score+".");
		}
		fin.close();
	}

	public static int getScore(char[][] grid, String search) {

		int best = 0;

		// (i,j) is location to start the search.
		for (int i=0; i<grid.length; i++) {
			for (int j=0; j<grid[0].length; j++) {

				// dx, dy indicates the direction in which to conduct the search.
				for (int dx=-1; dx<=1; dx++) {
					for (int dy=-1; dy<=1; dy++) {
						if (dx == 0 && dy == 0) continue;
						int temp = getScore(grid, search, i, j, dx, dy);
						if (temp > best)
							best = temp;
					}
				}
			}
		}

		return best;
	}

	// Scores the placement of search matching the first character at [startr][startc], moving in the
	// direction [dx][dy]. We assume startr, startc is inbounds!!!
	public static int getScore(char[][] grid, String search, int startr, int startc, int dx, int dy) {


		int endr = startr + dx*(search.length()-1);
		int endc = startc + dy*(search.length()-1);

		// Get rid of the invalid matches here.
		if (!inBounds(grid.length, grid[0].length, endr, endc)) return 0;

		int score = 0;
		for (int i=0; i<search.length(); i++) {
			if (search.charAt(i) == grid[startr+i*dx][startc+i*dy])
				score++;
		}

		// Case we got a perfect match!
		if (score == search.length())
			return MATCH;

		// Otherwise, this is our score.
		return score;

	}

	public static boolean inBounds(int numR, int numC, int r, int c) {
		return r >= 0 && r < numR && c >= 0 && c < numC;
	}
}