// Arup Guha
// 4/10/2020
// Solution to Code Jam Round 1A Problem: Pattern Matching
// Written in Contest, Commented afterwards.

import java.util.*;

public class a {
	
	public static int n;

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process cases.
		for (int loop=1; loop<=nC; loop++) {
		
			// Read in the words and also store their reverses.
			n = stdin.nextInt();
			String[] words = new String[n];
			String[] rev = new String[n];
			int[] starCnt = new int[n];
			for (int i=0; i<n; i++) {
				words[i] = stdin.next();
				rev[i] = reverse(words[i]);
				starCnt[i] = numStars(words[i]); 
			}
			
			// Get the required starting and ending lettters.
			String pre = getPre(words);
			String post = getPre(rev);
			if (post != null) post = reverse(post);
			
			// Inconsistency in the data, so no answer possible.
			if (pre == null || post == null)
				System.out.println("Case #"+loop+": *");
			
			// We can do it given their bounds for output string length.
			else {
				
				// We'll place everything in the middle so we can match all strings with > 1 star.
				StringBuffer mid = new StringBuffer();
				for (int i=0; i<n; i++) {
					
					// These are the ones we care about.
					if (starCnt[i] > 1) {
						
						// Find the indexes of the first and last star.
						int sI = words[i].indexOf('*');
						int eI = rev[i].length()-1-rev[i].indexOf('*');
						
						// Just put in all non-star characters, these stars are set to empty.
						for (int j=sI; j<=eI; j++)
							if (words[i].charAt(j) != '*')
								mid.append(words[i].charAt(j));
						
					}
					
				}
				
				// Ta da! 
				System.out.println("Case #"+loop+": "+pre+mid+post);
			}
		}
	}
	
	// Returns the common prefix before the first star in all words.
	public static String getPre(String[] words) {
		
		// Initial answer.
		String longPre = "";
		
		// Go through all words.
		for (int i=0; i<n; i++) {
			
			// We ignore these.
			if (words[i].charAt(0) == '*') continue;
			
			// Go to first star.
			int j = 0;
			while (words[i].charAt(j) != '*') j++;
			
			// This is our prefix.
			String thisPre = words[i].substring(0,j);
			
			// This is the longest one we've seen yet.
			if (thisPre.length() > longPre.length()) {
				
				// The starting portion of this doesn't match what we saw before, so inconsistent.
				if (!thisPre.substring(0, longPre.length()).equals(longPre))
					return null;
				
				// New longest.
				else
					longPre = thisPre;
			}
			
			// Not the longest - just need to check for consistency.
			else {
				if (!longPre.substring(0, thisPre.length()).equals(thisPre))
					return null;
			}
			
		}
		
		// Our result.
		return longPre;
	}
	
	// Returns the reverse of s.
	public static String reverse(String s) {
		char[] res = new char[s.length()];
		for (int i=0; i<s.length(); i++)
			res[s.length()-1-i] = s.charAt(i);
		return new String(res);
	}
	
	// Returns the # of stars in s.
	public static int numStars(String s) {
		int res = 0;
		for (int i=0; i<s.length(); i++)
			if (s.charAt(i) == '*')
				res++;
		return res;
	}
}