#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string name[111], a;
	int na, kazu[111], date[111][111], b;
	for (int i = 1; i <= 101; i++) {
		kazu[i] = 0;
	}
	na = 0;
	while (cin >> a >> b) {
		for (int i = 1; i <= na; i++) {
			if (name[i] == a) {
				kazu[i] = kazu[i] + 1;
				date[i][kazu[i]] = b;
				goto a;
			}
		}
		na = na + 1;
		name[na] = a;
		kazu[na] = 1;
		date[na][kazu[na]] = b;
	a:;
	}
	string aa;
	int bb,min,mi;
	for (int i = 1; i <= na; i++) {
		aa = "zzzzzzzzzzzzzzzzzzzzzzzzzzzz";
		for (int z = 1; z <= na; z++) {
			if (aa >= name[z]) {
				aa = name[z];
				bb = z;
			}
		}
		cout << aa << endl;
		name[bb] = "zzzzzzzzzzzzzzzzzzzzzzzz";
		for (int z = 1; z <= kazu[bb]; z++) {
			min = 9999;
			for (int m = 1; m <= kazu[bb]; m++) {
				if (date[bb][m] <= min) {
					min = date[bb][m];
					mi = m;
				}
			}
			cout << min << " ";
			date[bb][mi] = 9999;
		}
		cout << endl;
	}
}

