Problem:
Score: 300 points

Problem Statement

We have N voting papers. The i-th vote (1 \leq i \leq N) has the string S_i written on it.

Print all strings that are written on the most number of votes, in lexicographical order.

Constraints

1 \leq N \leq 2 \times 10^5

S_i (1 \leq i \leq N) are strings consisting of lowercase English letters.

The length of S_i (1 \leq i \leq N) is between 1 and 10 (inclusive).

Input

Input is given from Standard Input in the following format:

N
S_1
:
S_N

Output

Print all strings in question in lexicographical order.

Sample Input 1

7
beat
vet
beet
bed
vet
bet
beet

Sample Output 1

beet
vet

beet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.

Sample Input 2

8
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo

Sample Output 2

buffalo

Sample Input 3

7
bass
bass
kick
kick
bass
kick
kick

Sample Output 3

kick

Sample Input 4

4
ushi
tapu
nichia
kun

Sample Output 4

kun
nichia
tapu
ushi

Solution in C (GCC 5.4.1) (judge verdict: Time Limit Exceeded)

#include <stdio.h>

int main(){
  int n,i,j,k,l,o,p,b,r,c[200005][5],nn=0,f,m=1,d[200005][2];
  long h[200005];
  char s[200005][12];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",&s[nn]);
    h[nn]=0;
    for(j=0;j<10;j++){
      if(s[nn][j]==0) break;
      h[nn]|=((long)s[nn][j]-'a'+1)<<(9-j)*5;
    }
    if(nn==0){
      c[0][0]=-1;
      c[0][1]=-1;
      c[0][2]=1;
      c[0][3]=0;
      c[0][4]=-1;
      r=0;
      nn=1;
    }else{
      j=r;
      f=0;
      while(j!=-1){
        k=j;
        if(h[j]==h[nn]){
          c[j][2]++;
          if(m<c[j][2]) m=c[j][2];
          f=1;
          break;
        }
        j=c[j][h[j]<h[nn]];
      }
      if(f==0){
        c[nn][0]=-1;
        c[nn][1]=-1;
        c[nn][2]=1;
        c[nn][3]=1;
        c[nn][4]=k;
        c[k][h[k]<h[nn]]=nn;
        j=nn;
        while(c[j][3]){
          k=c[j][4];
          if(c[k][3]){
            l=c[k][4];
            p=c[l][c[l][0]==k];
            if(p!=-1){
              if(c[p][3]){
                c[k][3]=0;
                c[p][3]=0;
                c[l][3]=1;
                j=l;
                continue;
              }
            }
            if(c[k][1]==j){
              c[l][c[l][0]!=k]=j;
              c[j][4]=l;
              c[k][1]=c[j][0];
              c[j][0]=k;
              c[k][4]=j;
              o=j;
              j=k;
              k=o;
            }
            o=c[l][4];
            if(o!=-1){
              c[o][c[o][0]!=l]=k;
            }else{
              r=k;
            }
            c[k][4]=o;
            o=(c[l][0]==k);
            c[l][o^1]=c[k][o];
            c[k][o]=l;
            c[l][4]=k;
            c[k][3]=0;
            c[l][3]=1;
          }
          c[r][3]=0;
          break;
        }
        nn++;
      }
    }
  }
  i=0;
  d[0][0]=r;
  d[0][1]=0;
  while(i!=-1){
    f=0;
    switch(d[i][1]){
      case 0:
        d[i+1][0]=c[d[i][0]][0];
        if(d[i+1][0]!=-1) f=1;
        break;
      case 1:
        if(c[d[i][0]][2]==m){
          printf("%s\n",&s[d[i][0]]);
        }
        break;
      case 2:
        d[i+1][0]=c[d[i][0]][1];
        if(d[i+1][0]!=-1) f=1;
        break;
      default:
        i--;
    }
    if(f){
      i++;
      d[i][1]=0;
    }else{
      d[i][1]++;
    }
  }
  return(0);
}