// Arup Guha
// 11/11/2012
// Solution to 2012 South East Regional Problem (D2) F: Party Games

import java.util.*;

public class f {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();

		// Process each case.
		while (n != 0) {

			String[] names = new String[n];
			for (int i=0; i<n; i++)
				names[i] = stdin.next();

			// Setting this up is the easy part =)
			Arrays.sort(names);
			System.out.println(solve(names[n/2-1], names[n/2]));

			n = stdin.nextInt();
		}
	}

	// This function does the tough task of finding the shortest possible
	// division string, breaking ties alphabetically.
	public static String solve(String match, String after) {

		int firstLen = match.length();
		int lastLen = after.length();

		// Need to break our work into two cases.

		// We will build off the first string if it's shorter.
		if (firstLen <= lastLen){

			// Put this first, to avoid index out of bounds.
			if (match.substring(0, firstLen-1).equals(after.substring(0, firstLen-1)))
				return match;

			// Find first mismatch character - there is definitely one since we checked
			// for the prefix case already.
			int index = 0;
			while (match.charAt(index) == after.charAt(index))
				index++;

			// Use the string up to this point and then increment the last letter.
			return match.substring(0,index) + ((char)(match.charAt(index)+1));
		}

		// Here we'll build off the last string.
		else {

			// Find first mismatch character - there is definitely one since after
			// comes after match alphabetically so it can't be a substring of match.
			int index = 0;
			while (match.charAt(index) == after.charAt(index))
				index++;

			// There's a gap between the mismatched characters, so we can place a
			// unique character in between to make this word short as possible.
			if (after.charAt(index) - match.charAt(index) > 1) {
				return match.substring(0,index)+((char)(match.charAt(index)+1));
			}

			// NO GAP!
			else {

				// Mismatch char is at the end AND there is no gap.
				// We have to build off the first string.
				if (index+1 == after.length()) {

					// If we're in this case, we have to just add all Zs.
					index++;
					String ans = match.substring(0, index);
					while (index < match.length() && match.charAt(index) == 'Z') {
						index++;
						ans = ans + "Z";
					}

					// We can just append one more letter, making this strictly greater
					// than match.
					if (index < match.length()-1) {
						ans = ans + ((char)(match.charAt(index)+1));
						return ans;
					}

					// Can't do better than the first string itself.
					else {
						return match;
					}
				}

				// Mismatch isn't at the end, so just use a
				// proper substring of the last string.
				else {
					return after.substring(0,index+1);
				}
			}
		}
	}
}