#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <set>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>


#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

using namespace std;

static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> paii;

map< string, vector<int> > book;

void solve()
{
	EACH(i, book)
	{
		cout << i->first << endl;
		
		FOR(j, 0, i->second.size()-1)
		{	
			cout << i->second[j];
			cout <<	' ';
		}
		
		cout << i->second[i->second.size()-1] << endl;
	}
	
	return;
}


int main()
{
	string str;
	int pg;
	
	while(cin >> str, !cin.eof())
	{
		cin >> pg;
		book[str].push_back(pg);
		
		sort(ALL(book[str]));
	}
	
	solve();
	
	return 0;
}