// Arup Guha
// Written sometime in 2019 for Code Jam
// Downloaded to post for COP 4516

import java.util.*;

public class Solution {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process each case.
		for (int loop=1; loop<=nC; loop++) {
		
			// Read in the words in reverse.
			int n = stdin.nextInt();
			char[][] words = new char[n][];
			for (int i=0; i<n; i++)
				words[i] = reverse(stdin.next().toCharArray());
				
			// Insert the words.
			trienode root = new trienode();
			for (int i=0; i<n; i++)
				root.insert(words[i], 0);
				
			// Ta da!
			System.out.println("Case #"+loop+": "+root.go(0));
		}
	}
	
	public static char[] reverse(char[] arr) {
		char[] res = new char[arr.length];
		for (int i=0; i<arr.length; i++)
			res[arr.length-1-i] = arr[i];
		return res;
	}
}

class trienode {

	public int freq;
	public trienode[] next;
	
	public trienode() {
		freq = 0;
		next = new trienode[26];
		Arrays.fill(next, null);
	}
	
	public void insert(char[] word, int k) {
	
		// One more word with this prefix.
		freq += 1;
		
		// Done inserting.
		if (k == word.length) return;
		
		// Create the next link if we need it.
		if (next[word[k]-'A'] == null)
			next[word[k]-'A'] = new trienode();
			
		// Recursively insert the rest of the word.
		next[word[k]-'A'].insert(word, k+1);	
	}
	
	public int go(int depth) {
	
		// Base cases.
		if (freq == 2 && depth > 0) return 2;
		if (freq < 2) return 0;
		
		// Add up everything from the subtrees.
		int res = 0;
		for (int i=0; i<26; i++)
			if (next[i] != null)
				res += next[i].go(depth+1);
				
		// Match up 2 unmatched words at this top level as long as it's not the root.
		if (freq - res >= 2 && depth > 0) res += 2;
	
		return res;
	}

}