#include<iostream>
#include<cstring>
using namespace std;
char qiujiu[1005][1005];
int changdu[1005];
char mingzi[1005][1005];
int main(){
freopen("save.in", "r", stdin);
freopen("save.out", "w", stdout);
int renshu;
int jishu[1005];
cin>>renshu;
for(int i=1;i<=renshu;i++){
scanf("%s",mingzi[i]);
scanf("%s",qiujiu[i]);
changdu[i]=strlen(qiujiu[i]);
jishu[i]=0;
}
for(int m=1;m<=renshu;m++){
for(int n=0;n<=changdu[m];n++){
if(qiujiu[m][n]=='s'&&qiujiu[m][n+1]=='o'&&qiujiu[m][n+2]=='s'){
jishu[m]+=1;
}
}
}
int zuida=0;
for(int o=1;o<=renshu;o++){
if(jishu[o]>zuida){
zuida=jishu[o];
}
}
int zuizhong[1000];
int qaq=0;
for(int o=1;o<=renshu;o++){
if(jishu[o]==zuida){
qaq+=1;
zuizhong[qaq]=o;
}
}
for(int y=1;y<qaq;y++){
cout<<mingzi[zuizhong[y]]<<" ";
}
cout<<mingzi[zuizhong[qaq]]<<endl<<zuida;
return 0;
}