function main() {
  var
  i,
  line, words,
  dict = {},
  len = input.length;
  input.forEach(function(line) {
    if(line.trim() === '') return;
    line = line.split(' ');
    if(!dict[line[0]]) {
      dict[line[0]] = [];
    }
    dict[line[0]].push(parseInt(line[1], 10));
  });
  words = Object.keys(dict);
  words.sort();
  words.forEach(function(word) {
    dict[word].sort(function(a, b){
      return a - b;
    });
    console.log(word);
    console.log(dict[word].join(' '));
  });
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});