#include #include #include #include using namespace std; int main() { string nameA, nameB, goalA, goalB; map score, goals; while (cin >> nameA >> nameB >> goalA >> goalB) { if (goalA > goalB) score[nameA] += 3; else if (goalB > goalA) score[nameB] += 3; else { score[nameA] += 1; score[nameB] += 1; } goals[nameA] += 1; goals[nameB] += 1; } vector< tuple > teams; for (auto &x : goals) teams.push_back(make_tuple(-score[x.first], -goals[x.first], x.first)); sort(teams.begin(), teams.end()); for (auto &p : teams) cout << get<2>(p) << "\n"; }