#include #include #include #include using namespace std; int n , i , m , crt , nre , nr1 , nr2 , j , p[10] , gol[10]; char mat[5][100] , S[500] , aux[100] , e1[100] , e2[100]; bool ok1 , ok2; int main() { /*freopen("tour.in","r",stdin); freopen("tour.out","w",stdout); */ for (i = 1; i <= 6; ++i) { nr1 = nr2 = 0; ok1 = ok2 = false; cin.getline(S , 500); crt = -1; m = strlen(S); e1[0] = e1[1] = e2[0] = e2[1] = 0; while (S[++crt] != ' ') { aux[0] = S[crt]; aux[1] = 0; strcat(e1 , aux); } while (S[++crt] != ' ') { aux[0] = S[crt]; aux[1] = 0; strcat(e2 , aux); } while (S[++crt] != ' ') { nr1 = nr1 * 10 + S[crt] - '0'; } while (S[++crt] >= '0' && S[crt] <= '9') { nr2 = nr2 * 10 + S[crt] - '0'; } for (j = 1; j <= nre; ++j) if (strcmp(mat[j] , e1) == 0) { if (nr1 > nr2) p[j] += 3; if (nr1 == nr2) p[j]++; ok1 = true; gol[j] += nr1; } else if (strcmp(mat[j] , e2) == 0) { if (nr2 > nr1) p[j] += 3; if (nr2 == nr1) p[j]++; ok2 = true; gol[j] += nr2; } if (!ok1) { strcpy(mat[++nre],e1); if (nr1 > nr2) p[nre] += 3; if (nr1 == nr2) p[nre]++; gol[nre] += nr1; } if (!ok2) { strcpy(mat[++nre],e2); if (nr2 > nr1) p[nre] += 3; if (nr1 == nr2) p[nre]++; gol[nre] += nr2; } } for (i = 1; i <= 3; ++i) for (j = i + 1; j <= 4; ++j) if (p[j] > p[i]) { strcpy(aux , mat[i]); strcpy(mat[i] , mat[j]); strcpy(mat[j] , aux); swap(p[i] , p[j]); } else if (p[j] == p[i] && gol[j] > gol[i]) { strcpy(aux , mat[i]); strcpy(mat[i] , mat[j]); strcpy(mat[j] , aux); swap(p[i] , p[j]); } else if (p[j] == p[i] && gol[i] == gol[j] && strcmp(mat[j] , mat[i]) < 0) { strcpy(aux , mat[i]); strcpy(mat[i] , mat[j]); strcpy(mat[j] , aux); swap(p[i] , p[j]); } /*for (i = 1; i <= 4; ++i) puts(mat[i]);*/ for (i = 1; i <= 4; ++i) cout << mat[i] << '\n'; return 0; }