import java.util.*;
import java.io.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNext()) { // 注意 while 处理多个 case
String str = in.nextLine();
int n = Integer.parseInt(str);
String[] s = new String[n];
for(int i = 0 ; i < n; i++) {
s[i] = in.nextLine();
}
if(isOrderIex(s) && isOrderLen(s)) {
System.out.println("both");
} else if(isOrderIex(s)) {
System.out.println("lexicographically");
} else if(isOrderLen(s)) {
System.out.println("lengths");
} else {
System.out.println("none");
}
}
}
public static boolean isOrderIex(String[] s) {
for(int i = 0 ; i < s.length-1; i++) {
if(s[i].compareTo(s[i+1]) > 0) {
return false;
}
}
return true;
}
public static boolean isOrderLen(String[] s) {
for(int i = 0 ; i < s.length-1; i++) {
if(s[i].length() > s[i+1].length()) {
return false;
}
}
return true;
}
}