#include #include #include #include using namespace std; string A, B; int GoalsA, GoalsB; map > Map; pair > Teams[4]; int main() { for(int i = 1; i <= 6; ++ i) { cin >> A >> B >> GoalsA >> GoalsB; Map[A].first += GoalsA; Map[B].first += GoalsB; if(GoalsA > GoalsB) Map[A].second += 3; else if(GoalsA == GoalsB) Map[A].second += 1, Map[B].second += 1; else Map[B].second += 3; } int Cnt = 0; for(map > :: iterator it = Map.begin(); it != Map.end(); ++ it) Teams[Cnt] = make_pair(it -> second.second, make_pair(it -> second.first, it -> first)), Cnt ++; sort(Teams, Teams + 4); for(int i = 3; i >= 0; -- i) cout << Teams[i].second.second << "\n"; }