#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <time.h>
bool cmp(char a[],char b[]){
int lena=strlen(a),lenb=strlen(b);
if(lena>lenb||lena==lenb&&strcmp(a,b)>0)return true;
else return false;
}
int main(){
int n,maxid=1;
char max[101];
scanf("%d",&n);
fflush(stdin);
gets(max);
for(int i=2;i<=n;i++){
char temp[101];
gets(temp);
if(cmp(temp,max)){
strcpy(max,temp);
maxid=i;
}
}
printf("%d\n%s",maxid,max);
return 0;
}