#include<iostream>
#pragma warning(disable:4786)
#include<map>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string a;
	map<string, vector<int>> d;
	for(int l=0;l<8;l++){
		getline(cin, a);
		string b, h = "";
		int c, sum = 0;
		a += " ";
		for (int i = 0; i < a.length(); i++) {
			if (a[i] == ' ') {
				if (sum == 0)
					b = h;
				else
					c = atoi(h.c_str());
				sum++;
				h = "";
			}
			else
				h += a[i];
		}
		d[b].push_back(c);
		d[b].clear();
		d[b].push_back(c);
	}
	map<string, vector<int>>::iterator t = d.begin();
	while (t != d.end()) {
		string k = (*t).first;
		sort(d[k].begin(), d[k].end());
		cout << k << endl;
		for (int i = 0; i != d[k].size(); i++) {
			cout << " " << d[k][i];
		}
		cout << endl;
		t++;
	}
}