#include using namespace std; struct cell { int p,g; string s; }; struct comp { bool operator () (const cell &A,const cell &B) { if (A.p==B.p) { if (A.g==B.g) return A.sB.g; } return A.p>B.p; } }; int length; seta; set::iterator pit; string s1,s2; mapGoal; mapScore; map::iterator it; int main() { int l,x,y; cell kk; // freopen("date.in","r",stdin); // freopen("date.out","w",stdout); cin.sync_with_stdio(false); for (l=1;l<=6;l++) { cin>>s1>>s2>>x>>y; Goal[s1]+=x;Goal[s2]+=y; Score[s1]+=0;Score[s2]+=0; if (x!=y) { if (x>y) Score[s1]+=3; else Score[s2]+=3; } else {Score[s1]++;Score[s2]++;} } for (it=Score.begin();it!=Score.end();it++) { string longa=(*it).first; kk.s=longa; kk.p=Score[longa]; kk.g=Goal[longa]; a.insert(kk); } for (pit=a.begin();pit!=a.end();pit++) cout<<(*pit).s<<"\n"; return 0; }