#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void) {
long double max=0, t, log26=1.4149733;
int c, n, i, j, l;
char str[1001], maxS[1001];
while(c--){
max=1;
for(i=0;i<n;i++){
t=0;
if(l*log26<max) continue;
for(j=0;j<l;j++){
if(str[j] > 65) t+=log26;
else t++;
}
if(max<t){
max = t;
} else if(max==t){
if(str[j] < maxS[j]) {
break;
} else if(str[j]>maxS[j]) break;
}
}
}
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPG1hdGguaD4KaW50IG1haW4odm9pZCkgewoJbG9uZyBkb3VibGUgbWF4PTAsIHQsIGxvZzI2PTEuNDE0OTczMzsKCWludCBjLCBuLCBpLCBqLCBsOwoJY2hhciBzdHJbMTAwMV0sIG1heFNbMTAwMV07CglzY2FuZigiJWQiLCZjKTsKCXdoaWxlKGMtLSl7CgkJc2NhbmYoIiVkIiwmbik7CgkJbWF4PTE7CgkJZm9yKGk9MDtpPG47aSsrKXsKCQkJc2NhbmYoIiVzIixzdHIpOwoJCQl0PTA7CgkJCWw9c3RybGVuKHN0cik7CgkJCWlmKGwqbG9nMjY8bWF4KSBjb250aW51ZTsKCQkJZm9yKGo9MDtqPGw7aisrKXsKCQkJCWlmKHN0cltqXSA+IDY1KSB0Kz1sb2cyNjsKCQkJCWVsc2UgdCsrOwoJCQl9CgkJCWlmKG1heDx0KXsKCQkJCW1heCA9IHQ7CgkJCQltZW1jcHkobWF4Uywgc3RyLCBzdHJsZW4oc3RyKSsxKTsKCQkJfSBlbHNlIGlmKG1heD09dCl7CgkJCQlmb3Ioaj0wO2o8c3RybGVuKHN0cik7aisrKXsKCQkJCQlpZihzdHJbal0gPCBtYXhTW2pdKSB7CgkJCQkJCW1lbWNweShtYXhTLCBzdHIsIHN0cmxlbihzdHIpKzEpOwoJCQkJCQlicmVhazsKCQkJCQl9IGVsc2UgaWYoc3RyW2pdPm1heFNbal0pIGJyZWFrOwoJCQkJfQoJCQl9CgkJfQoJCXByaW50ZigiJXNcbiIsIG1heFMpOwoJfQoJcmV0dXJuIDA7Cn0=