#include #include #include #include #include using namespace std; map echipe; map goals; string st[4]; void swap_Str(int x, int y) { string temp_s; if (echipe[st[x]] < echipe[st[y]] ) { temp_s = st[x]; st[x] = st[y]; st[y] = temp_s; } else if (echipe[st[x]] == echipe[st[y]]) { if (goals[st[x]] < goals[st[y]]) { temp_s = st[x]; st[x] = st[y]; st[y] = temp_s; }else if (goals[st[x]] == goals[st[y]]) { if (st[x] < st[y]) temp_s = st[x]; st[x] = st[y]; st[y] = temp_s; } } } int main() { char a[50], b[50]; int x, y, i; //fscanf(stdin, "%s %s %d %d", a); for (i = 0; i < 6; ++i) { cin >> a >> b >> x >> y; goals[a] = x + goals[a]; goals[b] = y + goals[b]; if (x > y) { x = 3; y = 0; } else if (x < y) { x = 0; y = 3; } else { x = y = 1; } echipe[a] = x + echipe[a]; echipe[b] = y + echipe[b]; } i = 0; for( map::iterator ii=echipe.begin(); ii!=echipe.end(); ++ii) { st[i++] = (*ii).first; } swap_Str(0, 1); swap_Str(0, 2); swap_Str(0, 3); swap_Str(1, 2); swap_Str(1, 3); swap_Str(2, 3); } for (i = 0; i < 4; ++i) { cout << st[i] << '\n'; } return 0; }