1 #include<cstdio>
2 #include<cstring>
3 #include<string>
4 #include<iostream>
5 #include<algorithm>
6 using namespace std;
7
8 struct trie
9 {
10 trie *next[26];
11 int v;
12 trie()
13 {
14 memset(next,0,sizeof(next));
15 v=0;
16 }
17 };
18
19 int ans;
20 string ans_s;
21
22 trie *root=new trie;
23
24 void creatrie(char *s)
25 {
26 trie *p=root;
27 int len=strlen(s);
28 for(int i=0;i<len;i++)
29 {
30 int id=s[i]-'a';
31 if(p->next[id]==NULL)
32 {
33 trie *q=new trie;
34 p->next[id]=q;
35 p=p->next[id];
36 }
37 else
38 {
39 p=p->next[id];
40 }
41 if(i==len-1)
42 {
43 p->v+=1;
44 if(p->v>ans)
45 {
46 ans_s=s;
47 ans=p->v;
48 }
49 }
50 }
51 }
52
53 int main()
54 {
55 int n;
56 char s[11];
57 scanf("%d",&n);
58 while(n--)
59 {
60 scanf("%s",s);
61 creatrie(s);
62 }
63 cout<<ans_s<<" "<<ans<<endl;
64 return 0;
65 }