Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	dictionary := make(map[string][]int)

	for {
		var word string
		var page int
		fmt.Scanf("%s %d", &word, &page)

		if word == "" || page == 0 {
			break
		}

		pages := dictionary[word]
		pages = append(pages, page)
		dictionary[word] = pages
	}

	words := make([]string, 0)
	for i := range dictionary {
		words = append(words, i)
	}

	sort.Strings(words)

	for _, v := range words {
		sort.Ints(dictionary[v])
		fmt.Println(v)
		for i, page := range dictionary[v] {
			if i == len(dictionary[v])-1 {
				fmt.Printf("%d\n", page)
			} else {
				fmt.Printf("%d ", page)
			}
		}
	}
}

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0105&lang=jp
"""
import sys


def compile_index(dict, word, page):
    if word in dict:
        temp = dict[word]
        temp.append(page)
        temp.sort()
        dict[word] = temp
    else:
        temp = [page]
        dict[word] = temp


def main(args):
    index = {}
    for line in sys.stdin:
        word, page = line.strip().split(' ')
        page = int(page)
        compile_index(index, word, page)

    result = []
    for k, v in index.items():
        result.append((k, v))
    result.sort()
    for ele in result:
        print(ele[0])
        print(*ele[1])



if __name__ == '__main__':
    main(sys.argv[1:])

Python: # coding=utf-8

###
### for python program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    def pnum_check(self, n):
        if (n==1):
            return False
        elif (n==2):
            return True
        else:
            for x in range(2,n):
                if(n % x==0):
                    return False
            return True

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
# print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
# print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
# print(" {}".format(i), end="")

def printA(A):
    N = len(A)
    for i, n in enumerate(A):
        print(n, end='')
        if i != N-1:
            print(' ', end='')
    print()

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート
# N = N.sort()

# 10000個の素数リスト
# P = mymath.pnum_eratosthenes(105000)

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def dist(A, B):
    d = 0
    for i in range(len(A)):
        d += (A[i]-B[i])**2            
    d = d**(1/2)
    return d

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
        except EOFError:
            break
    return N

D = get_input()

A = {}

for d in D:
    s, p = [x for x in d.split()]
    p = int(p)
    if s in A:
        A[s].append(p)
    else:
        A[s] = [p]

B = sorted(A)

for i in B:
    L = sorted(list(A[i]))
    print(i)
    printA(L)

Python: book = {}
while True:
    a = b = 0
    try:
        a, b = input().split()
        b = int(b)
        if a in book:
            book[a].append(b)
        else:
            book[a] = [b]
    except:
        break
for i, m in sorted(book.items(), key = lambda x: x[0]):
    print(i)
    print(" ".join(str(j) for j in sorted(m)))

Python: index={}
while True:
    try:
        word,page=input().split(" ")
        page=int(page)
        tmp=index.get(word,[])
        tmp.append(page)
        index[word]=tmp

    except EOFError:
        break


index=sorted(index.items())
for object in index:
    print(object[0])
    print(" ".join([str(i) for i in sorted(object[1])]))

Python: Date_lis = []
W_lis = []
while True:
    try:
        s,n = map(str,input().split())

        if s in W_lis:
            Date_lis[W_lis.index(s)][1].append(int(n))
        else:
            Date_lis.append([s,[int(n)]])
            W_lis.append(s)
        
    except :
        Date_lis = sorted(Date_lis)
        for i in range(len(Date_lis)):
            print(Date_lis[i][0])
            Num = sorted(Date_lis[i][1])
            for j in range(len(Date_lis[i][1]) - 1):
                
                print(Num[j],end = " ")
            print(Num[len(Date_lis[i][1]) - 1])
        
        break

Python: import sys
d={}
for e in sys.stdin:
 k,v=e.split()
 if k in d:d[k]+=[int(v)]
 else:d[k]=[int(v)]
for k in sorted(d):
 print(k)
 print(*sorted(d[k]))

Python: # -*- coding: utf-8 -*-

import sys
import os
from collections import defaultdict

d = defaultdict(list)

for s in sys.stdin:
    lst = s.split()
    word = lst[0]
    page = int(lst[1])
    d[word].append(page)

keys = list(d.keys())
keys.sort()
for key in keys:
    print(key)
    pages = d[key]
    pages.sort()
    print(*pages)

Python: dic = {}

while True:
  try:
    s, i = input().split()
    if s in dic:
      dic[s].append(int(i))
    else:
      dic[s] = [int(i)]

  except EOFError:
    break

for k, v in sorted(dic.items()):
  print(k)
  print(*sorted(v))

Python: c={}
while 1:
    try:
        a,b=input().split()
        if a in c.keys():c[a].append(int(b))
        else: c[a]=[int(b)]
    except:
        for i,j in sorted(c.items()):
            print(i)
            print(' '.join(map(str,sorted(j))))
        break

Python: data = []
while True:
    try:
        data.append(input())
    except EOFError:
        break

d = {}
for i in range(len(data)):
    i,n = data[i].split()
    if i in d:
        d[i].append(n)
    else:
        d[i] = [n]
d = sorted(d.items(), key = lambda x:x[0])
for i in range(len(d)):
    i,n = d[i]
    n = map(int,n)
    print(i)
    n = sorted(n)
    for i in range(len(n)-1):
        print(n[i], end = ' ')
    print(n[-1])

Python: def main():
    book_index = {}
    while True:
        try:
            word, page = input().split(' ')
            page = int(page)
            page_list = book_index.get(word)
            if page_list:
                page_list.append(page)
            else:
                book_index[word] = [page]
        except Exception:
            break

    for k in sorted(book_index.keys()):
        print(k)
        print(' '.join(map(str, (sorted(book_index.get(k))))))


if __name__ == '__main__':
    main()