#include #include #include #include #include using namespace std; vector> v; int contains(string name){ for(int i = 0; i < v.size(); i++) if(std::get<2>(v[i]) == name) return i; return -1; } int main() { // freopen("f.txt","r",stdin); for(int i = 0; i < 6; i++){ string s1,s2; int g1,g2,pos; cin >> s1 >> s2; cin >> g1 >> g2; if(g1 > g2){ if((pos = contains(s1)) == -1){ v.push_back(std::make_tuple(3,g1,s1)); } else v[pos] = std::make_tuple(get<0>(v[pos]) + 3, get<1>(v[pos]) + g1,s1); if((pos = contains(s2)) == -1){ v.push_back(std::make_tuple(0,g2,s2)); } else v[pos] = std::make_tuple(get<0>(v[pos]), get<1>(v[pos]) + g2,s2); } else if(g1 == g2){ if((pos = contains(s1)) == -1){ v.push_back(std::make_tuple(1,g1,s1)); } else v[pos] = std::make_tuple(get<0>(v[pos]) + 1, get<1>(v[pos]) + g1,s1); if((pos = contains(s2)) == -1){ v.push_back(std::make_tuple(1,g2,s2)); } else v[pos] = std::make_tuple(get<0>(v[pos]) + 1, get<1>(v[pos]) + g2,s2); } else{ if((pos = contains(s1)) == -1){ v.push_back(std::make_tuple(0,g1,s1)); } else v[pos] = std::make_tuple(get<0>(v[pos]), get<1>(v[pos]) + g1,s1); if((pos = contains(s2)) == -1){ v.push_back(std::make_tuple(3,g2,s2)); } else v[pos] = std::make_tuple(get<0>(v[pos]) + 3, get<1>(v[pos]) + g2,s2); } } sort(v.begin(),v.end(), [](const tuple& a, const tuple& b) -> bool { if(get<0>(a) != get<0>(b)) return std::get<0>(a) > std::get<0>(b); else if(get<0>(a) == get<0>(b)) if(get<1>(a) != get<1>(b)) return get<1>(a) > get<1>(b); else return get<2>(a) < get<2>(b); // return std::get<0>(a) > std::get<0>(b); }); for(int i = 0; i < 4; i++) cout << get<2>(v[i]) << '\n'; // cout << std::get<2>(v[0]) << endl; return 0; }