#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int max=0;
char ans[20];
struct node//结点
{
int count;
struct node *next[26];//每个结点有26个分支
};
struct node *root;//根结点
struct node *newset()
{
struct node *p;
p=(struct node *)malloc(sizeof(struct node));//动态分配内存
for(int i=0;i<26;i++)
{
p->next[i]=NULL;//结点置空
}
p->count=0;//计数器的值置为0
return p;
}
void insert(char *s)//插入
{
struct node *p;
p=root;
int len=strlen(s);
for(int i=0;i<len;i++)
{
if(p->next[s[i]-'a']==NULL)//判断是否为空
p->next[s[i]-'a']=newset();
p=p->next[s[i]-'a'];
}
p->count++;
if(p->count>max)
{ max=p->count;
strcpy(ans,s);//保存最长的字符串
}
}
int main()
{
int n;
char chr[12];
root=newset();
scanf("%d",&n);
while(n--)
{
scanf("%s",chr);
insert(chr);
}
printf("%s %d\n",ans,max);
return 0;
}