// Arup Guha
// 10/13/2015
// Solution to 2005 UCF HS Contst Problem: Casey's Shortest Path

import java.util.*;

public class cycle {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int loop = 1;

		// Process each case
		while (n != 0) {

			// Build the string - when you find a repeat, cut off the portion in between the repeated character.
			String res = "";
			for (int i=0; i<n; i++) {
				String next = stdin.next();
				if (!res.contains(next)) res = res + next;
				else {
					int index = res.indexOf(next.charAt(0));
					res = res.substring(0, index+1);
				}
			}

			// Print result with spaces.
			System.out.print("Case "+loop+":");
			for (int i=0; i<res.length(); i++)
				System.out.print(" "+res.charAt(i));
			System.out.println();

			// Get next case.
			n = stdin.nextInt();
			loop++;
		}
	}
}