// Arup Guha
// 7/10/09
// Solution to BHCSI Homework Problem: String Class Practice, Part A

import java.util.*;

public class Alpha {
	
	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		
		// Get the number of words.
		System.out.println("How many words are you going to enter?");
		int n = stdin.nextInt();
		
		
		System.out.println("Enter the words.");
		
		// Store the first word as the earliest seen alphabetically.
		String first = stdin.next();
		
		// Loop through the rest of the words.
		for (int i=1; i<n; i++) {
			
			String tmp = stdin.next();
			
			// If the lowercase version of this new word comes first, update it!
			if  ( (tmp.toLowerCase()).compareTo(first.toLowerCase()) < 0 )
				first = tmp;
		}		
			
		// Print out the string that comes first.
		System.out.println("The first word alphabetically is "+first);
	}
}