#include<iostream>
#include<string>
using namespace std;
void f(int n, int m, string *temp, int *a)
{
int j = 0;
for (int i = 0; i < n; i++)
{
if (temp[m] == temp[i])
j++;
}
a[m] = j;
m++;
if (m < n) f(n, m, temp, a);
}
int main()
{
int n, m = 0, j = 0;
int max = 0;
while (cin >> n&& n != 0)
{
string *temp = new string[n]; int *a = new int[n];
for (int i = 0; i < n; i++)
{
cin >> temp[i];
}
f(n, m, temp, a);
for (int i = 0; i < n; i++)
{
if (a[i]>max)
{
max = a[i];
j = i;
}
}
if (max == 1) cout << "0" << endl;
else
cout << temp[j] << endl;
max = 0;
j = 0;
}
return 0;
}
#include<string>
using namespace std;
void f(int n, int m, string *temp, int *a)
{
int j = 0;
for (int i = 0; i < n; i++)
{
if (temp[m] == temp[i])
j++;
}
a[m] = j;
m++;
if (m < n) f(n, m, temp, a);
}
int main()
{
int n, m = 0, j = 0;
int max = 0;
while (cin >> n&& n != 0)
{
string *temp = new string[n]; int *a = new int[n];
for (int i = 0; i < n; i++)
{
cin >> temp[i];
}
f(n, m, temp, a);
for (int i = 0; i < n; i++)
{
if (a[i]>max)
{
max = a[i];
j = i;
}
}
if (max == 1) cout << "0" << endl;
else
cout << temp[j] << endl;
max = 0;
j = 0;
}
return 0;
}