package finalset;

import java.util.*;

/**
 * See handout.
 * 
 * @author George
 *
 */
public class Problem4 {
	
	public static final String FAILURE = "NO LADDER";
	public static final String SUCCESS = "WORD LADDER";
	
	public static String process (ArrayList input) {
		String response = "";
		String lastWord = null;
		for (Iterator it = input.iterator(); it.hasNext();) {
			String word = (String) it.next();
			if (lastWord == null) {
				lastWord = word;
				continue;
			}
			
			// check to see if we are different by just one letter.
			int numDiff = 0;
			for (int i = 0 ; i < lastWord.length(); i++) {
				if (lastWord.charAt(i) != word.charAt(i)) {
					numDiff++;
				}
			}
			
			if (numDiff != 1) {
				response += FAILURE + "\n";
				response += "BROKEN BY " + word + "\n";
				return response;
			}
			
			// move on.
			lastWord = word;
		}
		
		return SUCCESS + "\n";
	}
	
	public static void main (String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.valueOf(sc.nextLine());
		
		ArrayList al = new ArrayList();
		while (N-- > 0) {
			String word = sc.nextLine();
			al.add(word);			
		}
		
		System.out.println (process (al));
		
	}
}
