#include #include #include #include using namespace std; ifstream fin("date.in"); ofstream fout("date.out"); int goals1, goals2; char s[5][110], s1[110], s2[110]; struct data { int goals; int points; char s[110]; }team[10]; bool cmp(data a, data b) { if (a.points != b.points) return a.points > b.points; if (a.goals != b.goals) return a.goals > b.goals; return (strcmp(a.s, b.s) < 0); } int main() { for (int i = 1; i <= 6; i++) { cin >> s1 >> s2 >> goals1 >> goals2; int t1 = -1, t2 = -1; for (int j = 1; j <= 4; j++) { if (s[j][0] != 0 && strcmp(s[j], s1) == 0){ t1 = j; break; } if (s[j][0] == 0 && t1 == -1){ t1 = j; strcpy(team[t1].s, s1); for (int k = 0; k < strlen(s1); k++) s[j][k] = s1[k]; break; } } for (int j = 1; j <= 4; j++) { if (s[j][0] != 0 && strcmp(s[j], s2) == 0){ t2 = j; break; } if (s[j][0] == 0 && t2 == -1){ t2 = j; strcpy(team[t2].s, s2); for (int k = 0; k < strlen(s2); k++) s[j][k] = s1[k]; break; } } team[t1].goals += goals1; team[t2].goals += goals2; if (goals1 > goals2) team[t1].points += 3; else if (goals1 == goals2) { team[t1].points++; team[t2].points++; } else team[t2].points += 3; } sort(team + 1, team + 4 + 1, cmp); for (int i = 1; i <= 4; i++) cout << team[i].s << "\n"; return 0; }