#include using namespace std; string s; vector v; map , bool > > mp; inline bool cmp(string it1, string it2) { if (mp[it1].first.first < mp[it2].first.first) return false; if (mp[it1].first.first == mp[it2].first.first && mp[it1].first.second < mp[it2].first.second) return false; if (mp[it1].first.first == mp[it2].first.first && mp[it1].first.second == mp[it2].first.second && it1 > it2) return false; return true; } inline int atoii(string a) { int nr = 0 , ind = 0; for ( ; ind < a.size(); nr = nr * 10 + (a[ind] - '0'), ++ind); return nr; } int main() { #ifndef ONLINE_JUDGE freopen("input" , "r", stdin); freopen("output" , "w", stdout); #endif // ONLINE_JUDGE for (int i = 1; i<=6; ++i) { string a , b; a.clear() , b.clear(); cin >> s; int nr1 = 0, nr2 = 0; int ind = 0, len = s.size() - 1; a += s; cin >> s; b += s; cin >> s; nr1 = atoii(s); cin >> s; nr2 = atoii(s); bool ok1 = false , ok2 = false; /* while (ind <= len) { if (ok1 == false) { ok1 = true; while(isalpha(s[ind])) a += s[ind] , ++ind; ++ind; } else if (ok2 == false) { ok2 = true; while(isalpha(s[ind])) b += s[ind] , ++ind; ++ind; } else { while (isdigit(s[ind])) nr1 = nr1 * 10 + (s[ind] - '0') , ++ind; ++ind; while (ind <= len && isdigit(s[ind])) nr2 = nr2 * 10 + (s[ind] - '0') , ++ind; } }*/ int puncte1 = 0, puncte2 = 0; if (nr1 > nr2) puncte1 = 3; else if (nr1 < nr2)puncte2 = 3; else puncte1 = puncte2 = 1; mp[a].first.first += puncte1 , mp[a].first.second += nr1; mp[b].first.first += puncte2 , mp[b].first.second += nr2; if (mp[a].second == false) mp[a].second = true, v.push_back(a); if (mp[b].second == false) mp[b].second = true, v.push_back(b); } for (int i = 0; i<3; ++i) for (int j = i + 1; j<=3; ++j) { string it1 = v[i] , it2 = v[j]; if (it1 == it2) continue; if (mp[it1].first.first < mp[it2].first.first) swap(v[i] , v[j]); else if (mp[it1].first.first == mp[it2].first.first && mp[it1].first.second < mp[it2].first.second) swap(v[i] , v[j]); else if (mp[it1].first.first == mp[it2].first.first && mp[it1].first.second == mp[it2].first.second && it1 > it2) swap(v[i] , v[j]); } for (auto &it : v) cout << it << '\n'; return 0; }