#include using namespace std; struct cell { int val; char kk[1000]; }; const int baza=37; const int MODULO=666013; char s1[1000],s2[1000]; cell a[10]; mapGoal; mapScore; mapviz; inline bool Test( char *t,char *p) { int i,len1,len2; len1=strlen(t+1); len2=strlen(p+1); if (len1len2) return 0; for (i=1;i<=len1;i++) { if (t[i]p[i]) return 0; } return 0; } inline bool cmp (cell A,cell B) { if (Score[A.val]==Score[B.val]) { if (Goal[A.val]==Goal[B.val]) return A.kkGoal[B.val]; } return Score[A.val]>Score[B.val]; } int main() { int i,l,length=0,x,y,aux,paux,len1,len2; char A[5],B[5]; //freopen("date.in","r",stdin); //freopen("date.out","w",stdout); cin.sync_with_stdio(false); for (l=1;l<=6;l++) { cin>>(s1+1)>>(s2+1)>>(A+1)>>(B+1); len1=strlen(s1+1);len2=strlen(s2+1); aux=paux=0; for (i=1;i<=len1;i++) aux=(1LL*aux*baza+s1[i]-'a'+1)%MODULO; for (i=1;i<=len2;i++) paux=(1LL*paux*baza+s2[i]-'a'+1)%MODULO; if (viz.find(aux)==viz.end()) { a[++length].val=aux; for (i=1;i<=len1;i++) a[length].kk[i]=s1[i]; viz[aux]=1; Goal[aux]=0; Score[aux]=0; } if (viz.find(paux)==viz.end()) { a[++length].val=paux; for (i=1;i<=len2;i++) a[length].kk[i]=s2[i]; viz[paux]=1; Goal[paux]=0; Score[paux]=0; } len1=strlen(A+1);len2=strlen(B+1); x=y=0; for (i=1;i<=len1;i++) x=x*10+A[i]-'0'; for (i=1;i<=len2;i++) y=y*10+B[i]-'0'; Goal[aux]+=x;Goal[paux]+=y; if (x!=y) { if (x>y) Score[aux]+=3; else Score[paux]+=3; } else { Score[aux]++;Score[paux]++; } } sort(a+1,a+length,cmp); for (i=1;i<=length;i++) cout<<(a[i].kk+1)<<"\n"; return 0; }