bool lengths(){
int i=0;
while(i<()-1){
if(vec[i].size()>vec[i+1].size())
{
return 0;
}
i++;
}
return 1;
}
int main(){
int i=0,n;
string str;
bool r1,r2;
cin>>n;
while(i<n){
cin>>str;
vec.push_back(str);//把字符串str压进容器,vec.pop_back();//取出容器中最后一个
i++;
}
r1=lexicographically();
r2=lengths();
if(r1&&r2){
cout<<"both";
}
else if(r1&&(!r2)){
cout<<"lexicographically";
}
else if((!r1)&&r2){
cout<<"lengths";
}
else{
cout<<"none";
}
return 0;
}