#include<map>
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;
map<int,int>people;
vector<pair<int,int> >frs;
pair<int,int>p;
int ma;
inline bool exist(){
for(vector<pair<int,int> >::iterator iter=frs.begin();iter!=frs.end();iter++)
if((iter->first==p.first && iter->second==p.second) or (iter->second==p.first && iter->first==p.second))return true;
return false;
}
signed main(){
scanf("%d%d",&p.first,&p.second);
while(scanf("%d%d",&p.first,&p.second)!=EOF)
if(!exist()){
frs.push_back(p);
people[p.first]++;
people[p.second]++;
}
for(map<int,int>::iterator iter=people.begin();iter!=people.end();iter++)ma=max(ma,iter->second);
for(map<int,int>::iterator iter=people.end();iter!=people.begin();iter--)
if(ma==iter->second){
printf("%d",iter->first);
break;
}
return 0;
}
开O2最后一个点爆TLE,不开5~10全爆