#include #include #include #include #include #include #include using namespace std; char a[128], b[128], ga, gb; map score, goluri; vector< pair > > v; set countries; int main() { //freopen ("b.in", "r", stdin); while (scanf ("%s %s %d %d\n", &a, &b, &ga, &gb) == 4) { goluri[a] += ga; goluri[b] += gb; if (ga == gb) score[a] += 1, score[b] += 1; else if (ga > gb) score[a] += 3; else score[b] += 3; countries.insert(a); countries.insert(b); memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); } for (set::iterator it = countries.begin(); it != countries.end(); ++it) v.push_back( make_pair( score[*it], make_pair( goluri[*it], *it) ) ); //printf ("%s %d\n", it->first, it->second); sort(v.begin(), v.end()); reverse(v.begin(), v.end()); for (int i = 0; i < v.size(); ++i) printf ("%s\n", v[i].second.second.c_str()); }