#include #include #include using namespace std; int i,x1,x2,g1,j,g2,k,p[5],g[6]; char t1[104],t2[104],s3[104],a[5][104]; int main () { //freopen("input","r",stdin); //freopen("output","w",stdout); for(i=1;i<=6;i++) { scanf("%s%s%d%d",&t1,&t2,&g1,&g2); x1=0; x2=0; for(j=1;j<=k;j++) if(strcmp(t1,a[j])==0){x1=j;break;} for(j=1;j<=k;j++) if(strcmp(t2,a[j])==0){x2=j;break;} if(x1==0) { k++; x1=k; strcpy(a[k],t1); } if(x2==0) { k++; x2=k; strcpy(a[k],t2); } g[x1]+=g1; g[x2]+=g2; if(g1>g2) p[x1]+=3; else if(g10) { swap(p[i],p[j]); swap(g[i],g[j]); strcpy(s3,a[i]); strcpy(a[i],a[j]); strcpy(a[j],s3); } } for(i=1;i<=4;i++) printf("%s\n",a[i]); return 0; }