#include #include using namespace std; string teams[4]; int points[4], goals_scored[4]; bool swap(int a, int b) { return points[a] < points[b] || (points[a] == points[b] && goals_scored[a] < goals_scored[b]) || (points[a] == points[b] && goals_scored[a] == goals_scored[b] && teams[a] > teams[b]); } void sort() { for (int i = 0; i < 4; i++) for (int j = i + 1; j < 4; j++) if (swap(i, j)) { string t = teams[i]; teams[i] = teams[j]; teams[j] = t; int k = points[i]; points[i] = points[j]; points[j] = k; k = goals_scored[i]; goals_scored[i] = goals_scored[j]; goals_scored[j] = k; } } int main() { string team1, team2; int p1, p2; for (int i = 0; i < 6; i++) { cin >> team1 >> team2 >> p1 >> p2; int pos1 = -1, pos2 = -1; for (int j = 0; j < 4 && (pos1 == -1 || pos2 == -1); j++) if (teams[j].size() == 0) { if (pos1 == -1) { pos1 = j; teams[j] = team1; } else if (pos2 == -1) { pos2 = j; teams[j] = team2; } } else if (pos1 == -1 && teams[j] == team1) pos1 = j; else if (pos2 == -1 && teams[j] == team2) pos2 = j; if (p1 == p2) { points[pos1] += 1; points[pos2] += 1; } else { if (p1 > p2) points[pos1] += 3; else points[pos2] += 3; } goals_scored[pos1] += p1; goals_scored[pos2] += p2; } sort(); for (int i = 0; i < 4; i++) cout << teams[i] << "\n"; return 0; }