// Задача "Олимпийские игры"
// Шестая индивидуальная Интернет-олимпиада сезона 2009-2010.
// Автор задачи: Федор Царев, tsarev@rain.ifmo.ru
// Автор решения: Антон Ахи, akhi@rain.ifmo.ru

{$APPTYPE CONSOLE}
uses
  SysUtils;
var
  names : array [1..300] of string;
  medals : array[1..300, 1..3] of longint;
  n, i, j, k, m, num, l : longint;
  s : string;
  country : string;
  best : longint;

Begin
  Reset(Input, 'olympic.in');
  ReWrite(Output, 'olympic.out');
  m := 0;
  readln(n);
  for i := 1 to n do begin
    readln(s);
    j := 1;
    for k := 1 to n do begin
      country := '';
      while (j <= length(s)) and (s[j] <> ' ') do begin
        country := country + s[j];
        inc(j);
      end;
      while (j <= length(s)) and (s[j] = ' ') do
        inc(j);
      num := 0;
      for l := 1 to m do
        if (names[l] = country) then
          num := l;
      if (num = 0) then begin
        inc(m);
        names[m] := country;
        for l := 1 to 3 do
          medals[m, l] := 0;
        num := m;  
      end;
      inc(medals[num, k]);
    end;
  end;
  best := 1;
  for i := 1 to m do
    if (medals[i][1] > medals[best][1]) or
      ((medals[i][1] = medals[best][1]) and (medals[i][2] > medals[best][2])) or
      ((medals[i][1] = medals[best][1]) and (medals[i][2] = medals[best][2]) and (medals[i][3] > medals[best][3])) or
      ((medals[i][1] = medals[best][1]) and (medals[i][2] = medals[best][2]) and (medals[i][3] = medals[best][3]) and (names[i] < names[best])) then
      best := i;
  writeln(names[best]);
  Close(Input);
  Close(Output);
End.
