#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, int> scores;
  map<string, vector<int> > wins;
  int n;
  cin >> n;
  for (int l = 0; l < n; l++) {
    int t;
    cin >> t;
    string arr[1000];
    for (int i = 0; i < t; i++) {
      cin >> arr[i];
      if (wins[arr[i]].size() == 0)
        for (int j = 0; j < 50; j++) wins[arr[i]].push_back(0);
    }
    for (int i = 0; i < t; i++) {
      wins[arr[i]][i]++;
      switch (i) {
        case 0:
          scores[arr[i]] += 25;
          break;
        case 1:
          scores[arr[i]] += 18;
          break;
        case 2:
          scores[arr[i]] += 15;
          break;
        case 3:
          scores[arr[i]] += 12;
          break;
        case 4:
          scores[arr[i]] += 10;
          break;
        case 5:
          scores[arr[i]] += 8;
          break;
        case 6:
          scores[arr[i]] += 6;
          break;
        case 7:
          scores[arr[i]] += 4;
          break;
        case 8:
          scores[arr[i]] += 2;
          break;
        case 9:
          scores[arr[i]] += 1;
          break;
      }
    }
  }
  int m = -1;
  for (map<string, int>::iterator i = scores.begin(); i != scores.end(); ++i)
    if (i->second > m) m = i->second;
  vector<string> vvv;
  for (map<string, int>::iterator i = scores.begin(); i != scores.end(); ++i)
    if (i->second == m) vvv.push_back(i->first);
  if (vvv.size() == 1)
    cout << vvv[0] << endl;
  else {
    bool found = false;
    for (int k = 0; k < 50 && !found; k++) {
      int max_win = -1;
      for (int i = 0; i < vvv.size(); i++)
        if (wins[vvv[i]][k] > max_win) max_win = wins[vvv[i]][k];
      vector<string> ress;
      for (int i = 0; i < vvv.size(); i++)
        if (wins[vvv[i]][k] == max_win) ress.push_back(vvv[i]);
      if (ress.size() == 1) {
        cout << ress[0] << endl;
        found = true;
      } else {
        vvv.clear();
        for (int i = 0; i < ress.size(); i++) vvv.push_back(ress[i]);
      }
    }
  }
  int max_win = -1;
  for (map<string, int>::iterator i = scores.begin(); i != scores.end(); ++i)
    if (wins[i->first][0] > max_win) max_win = wins[i->first][0];
  vector<string> res;
  for (map<string, int>::iterator i = scores.begin(); i != scores.end(); ++i)
    if (wins[i->first][0] == max_win) res.push_back(i->first);
  if (res.size() == 1)
    cout << res[0] << endl;
  else {
    int mm = -1;
    for (int i = 0; i < res.size(); i++)
      if (scores[res[i]] > mm) mm = scores[res[i]];
    vector<string> ss;
    for (int i = 0; i < res.size(); i++)
      if (scores[res[i]] == mm) ss.push_back(res[i]);
    if (ss.size() == 1) {
      cout << ss[0] << endl;
      return 0;
    }
    for (int k = 1; k < 50; k++) {
      max_win = -1;
      for (int i = 0; i < ss.size(); i++)
        if (wins[ss[i]][k] > max_win) max_win = wins[ss[i]][k];
      vector<string> ress;
      for (int i = 0; i < ss.size(); i++)
        if (wins[ss[i]][k] == max_win) ress.push_back(ss[i]);
      if (ress.size() == 1) {
        cout << ress[0] << endl;
        return 0;
      } else {
        ss.clear();
        for (int i = 0; i < ress.size(); i++) ss.push_back(ress[i]);
      }
    }
  }
  return 0;
}
