// Arup Guha
// 4/12/2019
// Solution to Code Jam Round 1A Problem: Alien Rhyme (written in contest, commented later)

import java.util.*;
public class a {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();

		// Process all cases.
		for (int loop=1; loop<=nC; loop++) {
			
			// Store all words reversed in a trie.
			int n = stdin.nextInt();
			trie dictionary = new trie();
			for (int i=0; i<n; i++) {
				String word = reverse(stdin.next());
				dictionary.insert(word, 0);
			}
			
			// Solve it.
			System.out.println("Case #"+loop+": "+dictionary.solve(0));
		}
	}
	
	// Returns the reverse of s.
	public static String reverse(String s) {
		int n = s.length();
		char [] res = new char[n];
		for (int i=0,j=n-1;i<n;i++,j--)
			res[i] = s.charAt(j);
		return new String(res);
	}

}

class trie {

	public int numWords;
	public trie[] next;
	
	public trie() {
		numWords = 0;
		next = new trie[26];
		Arrays.fill(next, null);
	}
	
	// Inserts string s at level k of the trie.
	public void insert(String s, int k) {
		
		// One more word in this subtree.
		numWords++;
		if (k == s.length()) return;
		
		// Build a new node if we need one.
		if (next[s.charAt(k)-'A'] == null)
			next[s.charAt(k)-'A'] = new trie();
		
		// Recursively insert...
		next[s.charAt(k)-'A'].insert(s, k+1);
	}
	
	// Solves the problem for depth.
	public int solve(int depth) {
		
		// We can grab both...
		if (numWords == 2 && depth > 0) return 2;
		
		// Try adding all the words from subtrees.
		int res = 0;
		for (int i=0; i<26; i++) {
			if (next[i] != null)
				res += next[i].solve(depth+1);
		}
		
		// We can grab two more at this level if they are there to grab.
		if (numWords - res >=2 && depth != 0) res += 2;
		
		// In this case we can also grab 2.
		if (res == 0 && numWords > 1 && depth != 0) res += 2;
		
		return res;
	}

}