#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T abs(T a) {
  return a < 0 ? -a : a;
}
template <typename T>
inline T sqr(T a) {
  return a * a;
}
const int INF = (int)1E9 + 7;
const long double EPS = 1E-9;
const int NMAX = 1007;
int n;
struct com {
  string name;
  int cnt;
  int goal;
  int ngoal;
  com() { cnt = 0, goal = 0, ngoal = 0; }
  bool operator<(const com& a) const {
    if (cnt == a.cnt) {
      if (goal - ngoal == a.goal - a.ngoal) {
        return goal > a.goal;
      }
      return goal - ngoal > a.goal - a.ngoal;
    }
    return cnt > a.cnt;
  }
};
bool cmp(const com& a, const com& b) { return a.name < b.name; }
char tmp1[1000];
map<string, int> pos;
int main() {
  scanf("%d", &n);
  vector<com> a(n);
  getline(cin, a[0].name);
  for (int i = 0; i < int(n); ++i) {
    getline(cin, a[i].name);
    pos[a[i].name] = i;
  }
  string tmp;
  while (getline(cin, tmp)) {
    string s1, s2;
    int idx = 0;
    for (; tmp[idx] != '-'; idx++) s1 += tmp[idx];
    for (idx++; isalpha(tmp[idx]); idx++) s2 += tmp[idx];
    int c1, c2;
    sscanf(tmp.c_str(), "%s %d:%d", tmp1, &c1, &c2);
    int id1 = pos[s1], id2 = pos[s2];
    a[id1].goal += c1, a[id2].goal += c2;
    a[id1].ngoal += c2, a[id2].ngoal += c1;
    if (c1 == c2) {
      a[id1].cnt++, a[id2].cnt++;
    } else if (c1 < c2)
      a[id2].cnt += 3;
    else
      a[id1].cnt += 3;
  }
  sort((a).begin(), (a).end());
  sort(a.begin(), a.begin() + int((a).size()) / 2, cmp);
  for (int i = 0; i < int(int((a).size()) / 2); ++i) cout << a[i].name << endl;
  return 0;
}
