import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) throws IOException  {
        BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(r.readLine());
        String[] arr=new String[n];
        for (int i = 0; i < n; i++) {
            arr[i]=r.readLine();
        }
        int flag1=func1(arr);
        int flag2=func2(arr);
        if(flag1==1&&flag2==1){
            System.out.println("both");
        } else if (flag1==1) {
            System.out.println("lexicographically");
        } else if (flag2==1) {
            System.out.println("lengths");
        }else {
            System.out.println("none");
        }
    }
    public static int func1(String[] arr){
        for (int i = 0; i < arr.length-1; i++) {
            if(arr[i].compareTo(arr[i+1])>0){
                return 0;
            }
        }
        return 1;
    }
    public static int func2(String[] arr){
        for (int i = 0; i < arr.length-1; i++) {
            if(arr[i].length()>arr[i+1].length()){
                return 0;
            }
        }
        return 1;
    }
}