#if 1
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
#include<stdio.h>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<sstream>
using namespace std;
class A {
public:
string color;
int sum;
A(string str,int sum):color(str),sum(sum){}
bool operator==(const A& a)const {
return a.color == this->color;
}
};
class B {
public:
bool operator()(const A& a, const A& b)const {
if (a.sum == b.sum) {
return a.color.compare(b.color) < 0;
}
return a.sum > b.sum;
}
};
int main() {
int n; string color;
while (cin >> n) {
set<A,B>s;
if (n == 0)break;
for (int i = 0; i < n; ++i) {
cin >> color;
auto tem = find(s.begin(), s.end(), A(color, 0));
if (tem != s.end()) {
int sum = (tem->sum + 1);
s.erase(tem);
s.insert(A(color, sum));
}
else {
s.insert(A(color, 1));
}
}
cout<< s.begin()->color<<'\n';
}
}
#endif