#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double pi = 3.141592653589793238462;
const int nmax = 1000000;
const int hash_base = 119;
const long long inf = 2e18;
int T, n, maxScore = 0, maxWin[60];
string S;
map<string, int> score;
map<string, int> win[60];
vector<string> pot_win_s1;
set<string> Name;
int main() {
  cin >> T;
  for (int Q = 1; Q <= T; Q++) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> S;
      Name.insert(S);
      if (i == 1) score[S] += 25;
      if (i == 2) score[S] += 18;
      if (i == 3) score[S] += 15;
      if (i == 4) score[S] += 12;
      if (i == 5) score[S] += 10;
      if (i == 6) score[S] += 8;
      if (i == 7) score[S] += 6;
      if (i == 8) score[S] += 4;
      if (i == 9) score[S] += 2;
      if (i == 10) score[S] += 1;
      win[i][S]++;
      maxScore = max(maxScore, score[S]);
      maxWin[i] = max(maxWin[i], win[i][S]);
    };
  };
  for (set<string>::iterator it = Name.begin(); it != Name.end(); it++)
    if (score[*it] == maxScore) pot_win_s1.push_back(*it);
  for (int i = 1; i <= 60; i++) {
    if (pot_win_s1.size() == 1) {
      cout << pot_win_s1[0] << endl;
      break;
    };
    vector<string> pot_win_si;
    int LocMaxWin = 0;
    for (int j = 0; j < pot_win_s1.size(); j++)
      LocMaxWin = max(LocMaxWin, win[i][pot_win_s1[j]]);
    for (int j = 0; j < pot_win_s1.size(); j++)
      if (win[i][pot_win_s1[j]] == LocMaxWin)
        pot_win_si.push_back(pot_win_s1[j]);
    pot_win_s1 = pot_win_si;
  };
  pot_win_s1.clear();
  for (set<string>::iterator it = Name.begin(); it != Name.end(); it++)
    if (win[1][*it] == maxWin[1]) pot_win_s1.push_back(*it);
  if (pot_win_s1.size() == 1) {
    cout << pot_win_s1[0] << endl;
    return 0;
  };
  vector<string> pot_win_si;
  int locMaxScore = 0;
  for (int i = 0; i < pot_win_s1.size(); i++)
    if (score[pot_win_s1[i]] > locMaxScore) locMaxScore = score[pot_win_s1[i]];
  for (int i = 0; i < pot_win_s1.size(); i++)
    if (score[pot_win_s1[i]] == locMaxScore)
      pot_win_si.push_back(pot_win_s1[i]);
  pot_win_s1 = pot_win_si;
  for (int i = 2; i <= 60; i++) {
    if (pot_win_s1.size() == 1) {
      cout << pot_win_s1[0] << endl;
      break;
    };
    vector<string> pot_win_si;
    int LocMaxWin = 0;
    for (int j = 0; j < pot_win_s1.size(); j++)
      LocMaxWin = max(LocMaxWin, win[i][pot_win_s1[j]]);
    for (int j = 0; j < pot_win_s1.size(); j++)
      if (win[i][pot_win_s1[j]] == LocMaxWin)
        pot_win_si.push_back(pot_win_s1[j]);
    pot_win_s1 = pot_win_si;
  };
  return 0;
}
