var map = {};

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input) {
  input = input.split("\n");
  input.pop();
  for (var a in input) {
    var tmp = input[a].split(" ")
    var key = tmp[0];
    if(map[key] === undefined || map[key] == null) map[key] = [];
    map[key].push(tmp[1]);
  }
});
process.stdin.on('end', function() {
  var order = Object.keys(map).sort();
  var t;
  for (var k in order) {
    k = order[k];
    t = map[k].sort(function (a,b) {
      return a-b;
    });
    console.log(k);
    console.log(t.join(" "));
  }
});