#include<stdio.h> #include<malloc.h> #include<string.h> struct node { int date; struct node * p[26]; }root; char maxstr[15]; int maxnum; void init(node *p) { p->date=0; for(int i=0;i<26;i++) p->p[i]=NULL; } node * xin() { node *p=(node *)malloc(sizeof(node)); init(p); return p; } void add(char * str) { int n=strlen(str); node *p=&root; for(int i=0;i<n;i++) { if(p->p[str[i]-'a']==NULL) p->p[str[i]-'a']=xin(); p=p->p[str[i]-'a']; } p->date++; if(p->date>maxnum) { maxnum=p->date; strcpy(maxstr,str); } } int main() { // freopen("in.txt","r",stdin); init(&root); int n; char str[15]; scanf("%d",&n); maxnum=0; while(n--) { scanf("%s",str); add(str); } printf("%s %d\n",maxstr,maxnum); return 0; }