#include <iostream>
using namespace std;

struct STUDENT_SCORE
{
	char name[16];
	char id[16];
	int  eng;
};

#include <vector>

int main()
{
	vector< STUDENT_SCORE >	scores;
	char inputs[ 256 ];
	int  orders[101] = { 0 };

	while( cin.getline( inputs, sizeof inputs ) )
	{
		STUDENT_SCORE score;
		sscanf( inputs, "%s%s%u", score.name, score.id, &score.eng );
		scores.emplace_back( score );
		orders[ score.eng ]++;
	}

    int accumulation = scores.size();
	for( auto& order : orders )
	    order = ( accumulation -= order ) + 1;
	    
	for( const auto& score : scores )
		cout << score.name << " " << score.id << " " << score.eng << " "
		     << orders[ score.eng ] << endl;

	return 0;
}
