#define _CRT_SECURE_NO_DEPRECATE #define _USE_MATH_DEFINES #include /* */ using namespace std ; typedef long long LL ; typedef unsigned long long ULL ; typedef unsigned int uint; typedef unsigned char uchar; typedef vector vi ; typedef vector vvi ; typedef vector vs ; typedef vector vvs ; typedef pair pss ; typedef pair pdd; typedef pair pii ; typedef pair pll ; typedef pair puu; #define all(V) (V).begin(), (V).end() #define allr(V) (V).rbegin(), (V).rend() #define SET(Adr,val) memset(Adr,val,sizeof(Adr)) #define SET0(Adr) memset(Adr,0,sizeof(Adr)) #define CMP(Adr1,Adr2) memcmp(&Adr1,&Adr2,sizeof(Adr1)) #define FOR(it,a,b) for( int(it) = (int)a ; it<= (int(b)) ; ++it ) #define FORN(it,a,b) for( int(it) = (int)a ; it< (int(b)) ; ++it ) #define FORV(it,v) for( it = (v).begin() ; it!=(v).end() ; ++it ) #define FORMI(i,j,ii,jj,im,jm) for( int(i) = (int)ii ; i < (int)im ; ++i )\ for( int(j) = (int)jj ; j < (int)jm ; ++j ) #define FORMO(i,j,ii,jj,im,jm) for( int(i) = (int)ii ; i < (int)im ; ++i, cout << '\n')\ for( int(j) = (int)jj ; j < (int)jm ; ++j, cout << ' ' ) #define SHOWME(x) cerr << __LINE__ << ": " << #x << " = " << (x) <<'\n'; #define inchide cerr << "\nLine "<< __LINE__ << " just passed...EXIT\n" ;exit(-1); #define Cat(a,b) (double(a)/double(b)) #define Min(a,b) ((a>b)?b:a) #define Max(a,b) ((a>b)?a:b) #define Prod(a,b) ((a)*(b)) #define Pow2(a) ((a)*(a)) #define sz(x) ((int)(x).size()) #define forn(i,n) for(int i=0;i<(n);++i) #define fors(i,v) forn(i,sz(v)) #define MOD1 1000000007 #define NMAX 10000 #define NMAX2 20001 #define mp make_pair #define pb push_back #define fi first #define se second #define left asdleft #define right asdright #define link asdlink #define unlink asdunlink #define next asdnext #define prev asdprev const double Euler = 2.71828182845904523536 ; const double PI = 3.14159265358979323846 ; const double EPS = 1e-10; const int INF = 0x3fefefef ; const double DINF = 1e200; const LL LINF = INF*1ll*INF; const int dx[4] = { 0 ,-1 , 0 ,1 } ; const int dy[4] = { 1 , 0 ,-1 ,0 } ; /* |V1| |E3| |SV5| |SE7| */ const int dx8[8] = { 0 ,-1 ,0 ,1 ,1 ,-1 ,-1 , 1 } ; const int dy8[8] = { 1 , 0 ,-1 ,0 ,1 ,-1 , 1 ,-1 } ; /* |N0| |S2| |NE4| |NV6| */ template inline ostream& operator<<(ostream &out,const pair&__p) {return(out<<__p.fi<<' '<<__p.se<<'\n');} template inline istream& operator>>(istream &in,pair&__p) {in>>__p.fi>>__p.se;return(in);} template inline ostream& operator<<(ostream &out ,const pair&__p){ (out<<__p.fi<<' '<<__p.se<< '\n');} template inline istream& operator>>(istream &in ,pair&__p){ in>>__p.fi>>__p.se;return(in);} inline int toint(const string &s){istringstream iss(s);int res;iss>>res;return(res);} inline double dist2pct(int _x,int _y,int _z,int _w){return(sqrt(Pow2(_z-_x)+Pow2(_w-_y)));} templatestring tostr(const T &__x){ostringstream ss;ss<<__x;return(ss.str());} templateostream & arata(ostream &out ,const T &a){return(out<istream & citeste(istream &in ,T &a){return(in>>a);} templatevoid AddNr(T &a, T b){a=a+b;while(a>=MOD1)a-=MOD1;while(a<0)a+=MOD1;} templatevoid ReadNo(T&__no){T __sign=1;char ch;__no=0; while(!isdigit(ch=getchar()))(ch=='-')&&(__sign=-1); do{__no=(__no<<1)+(__no<<3)+(ch-48);}while(isdigit(ch=getchar()));__no*=__sign;} /******************************************************************************************/ map< string ,pii >Mp ; vector< pair < string , pii > >V ; struct Functor{ inline bool operator() ( pair < string , pii > A , pair < string , pii > B ){ return ( A.se.fi < B.se.fi || ( A.se.fi == B.se.fi && A.se.se < B.se.se ) || ( A.se.fi == B.se.fi && A.se.se == B.se.se && A.fi > B.fi ) ) ; } }; /******************************************************************************************/ /** MAIN **/ int main( int argc, char ** argv ){ cin.sync_with_stdio(false) ; // freopen("teams.in" , "r" , stdin ) ; char line[256]={0} ; while ( cin.getline(line,sizeof(line),'\n') ) { istringstream iss(line) ; string s1 , s2 ; int g1 , g2 ; iss >> s1 >> s2 >> g1 >> g2 ; Mp[s1].se+= g1 ; Mp[s2].se+= g2 ; if( g1 > g2 ) Mp[s1].fi+= 3 ; else if ( g1 < g2 ) Mp[s2].fi+= 3 ; else { ++Mp[s1].fi; ++Mp[s2].fi; } } vector < pair < string , pii > >:: reverse_iterator it ; map < string , pii > :: iterator raid ; FORV(raid,Mp) V.pb( pair< string , pii >( raid->fi,pii(raid->se.fi,raid->se.se )) ) ; sort( all(V) , Functor() ) ; for ( it = V.rbegin() ; it != V.rend() ; ++ it ) cout << it->fi << /* " P : " << it->se.fi << " G : " << it->se.se<< */" \n"; return (0); } /** MAIN **/