/*
* File: hdu1004.cpp
* Author: chenjiang
*字符串哈希函数的应用 hdu 1004
* Created on 2010年3月24日, 下午1:32
*/
#include <stdlib.h>
#include <iostream>
#include <string>
using namespace std;
char ch[1000],ch1[1000];
int a[1005];
//RS哈希
unsigned int RSHash(char *str) {
unsigned int b = 378551;
unsigned int a = 63689;
unsigned int hash = 0;
while (*str) {
hash = hash * a + (*str++);
a *= b;
}
return (hash & 0x7FFFFFFF);
}
/*
*
*/
int main(int argc, char** argv) {
int n, i, j, max;
while (cin >> n) {
if (n == 0)break;
memset(a, 0, sizeof (a));
max = 0;
for (i = 0; i < n; i++) {
cin >> ch;
a[RSHash(ch) % 1000]++;
if (a[RSHash(ch) % 1000] > max) {
max = a[RSHash(ch) % 1000];
strcpy(ch1,ch);
}
}
cout << ch1 << endl;
}
return (EXIT_SUCCESS);
}