#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string a;
	int b;
	string c[100];
	int d[100][1000];
	int g[100];
	for (int i = 0; i < 100; i++) {
		g[i] = 0;
	}
	int e = 0;
	while (cin >> a >> b) {
		int f;
		bool h = false;
		for (int i = 0; i < e; i++) {
			if (c[i] == a) {
				f = i;
				h = true;
				goto stop;
			}
		}
		c[e] = a;
		d[e][g[e]] = b;
		g[e]++;
		e++;
		stop:;
		if (h) {
			d[f][g[f]] = b;
			g[f]++;
		}
	}
	for (int i = 0; i < e; i++) {
		sort(d[i], d[i] + g[i]);
	}
	for (int i = 0; i < e; i++) {
		cout << c[i] << endl;
		for (int j = 0; j < g[i]; j++) {
			if (j == 0)
				cout << d[i][j];
			else
				cout << " " + d[i][j];
		}
		cout << endl;
	}
}