#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	string phrase;
	string page;
	string space = " ";
	vector<string> str;
	vector<string>::iterator p;
	p = str.begin();
	
	cin >> phrase >> page;
	phrase.append(space);
	phrase.append(page);
	str.push_back(phrase);
	
	while(cin >> phrase >> page){
	  //	cin >> phrase;
	  //	if(phrase == "end") break;
	  //	cin >> page;
		

		for(p = str.begin(); p != str.end(); p++){
			string a = *p;
			int b = a.find_first_of(" ", 0);
			string c = a.substr(0, b);
			if(phrase == c){
				phrase = *p;
				phrase += space;
				phrase += page;
				*p = phrase;
				break;
			}
		}
		if(p == str.end()){
			phrase.append(space);
			phrase.append(page);
			str.push_back(phrase);
		}
		
	}
	
	sort(str.begin(), str.end());
	for(p = str.begin(); p != str.end(); p++){
		cout << *p << endl;
	}

	return 0;
}