// Arup Guha
// 2/2/2014
// Solution to 2014 UCF HS Online Contest Problem: Track

import java.util.*;

public class who {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=1; loop<=numCases; loop++) {

			int n = stdin.nextInt();
			int q = stdin.nextInt();

			// Read in suspects as bitmask...
			int[] suspects = new int[n];
			for (int i=0; i<n; i++)
				suspects[i] = convert(stdin.next());

			int best = q;

			// Try each combination of questions.
			for (int i=1; i<(1 << q); i++) {

				// Basically, a bitwise and isolates the answers for this subset of questions.
				int match = i & suspects[0];
				boolean unique = true;

				// Try the rest to find a match.
				for (int j=1; j<n; j++) {
					if ((i & suspects[j]) == match) {
						unique = false;
						break;
					}
				}

				// Update best if necessary.
				if (unique && numbits(i) < best)
					best = numbits(i);
			}

			// Output result.
			System.out.println("Game #"+loop+": "+best);
		}
	}

	// Converts s to a bitmask;
	public static int convert(String s) {
		int mask = 0;
		for (int i=0; i<s.length(); i++) {
			mask = mask << 1;
			if (s.charAt(i) == 'Y') mask++;
		}
		return mask;

	}

	// Returns the number of 1 bits in n.
	public static int numbits(int n) {
		int cnt = 0;
		while (n > 0) {
			if ((n & 1) == 1) cnt++;
			n = n >> 1;
		}
		return cnt;
	}
}