d = {}

while True:

    try:

        word, page = input().split()

        page = int(page)

    except:

        break

    d[word] = [page] if word not in d else d[word] + [page]

for word, pages in sorted(d.items()):

    print(word)

    print((*sorted(pages)))
d = {}

while True:

    try:

        data = input().split()

    except:

        break

    word = data[0]

    number = int(data[1])

    if word in d:

        d[word].append(number)

    else:

        d[word] = [number]



for k, v in sorted(list(d.items()), key=lambda x: x[0]):

    print(k)

    print((*sorted(v)))



d = {}
while True:
    try:
        word, page = input().split()
        page = int(page)
    except:
        break
    d[word] = [page] if word not in d else d[word] + [page]
for word, pages in sorted(d.items()):
    print(word)
    print((*sorted(pages)))

d = {}
while True:
    try:
        data = input().split()
    except:
        break
    word = data[0]
    number = int(data[1])
    if word in d:
        d[word].append(number)
    else:
        d[word] = [number]
for k, v in sorted(list(d.items()), key=lambda x: x[0]):
    print(k)
    print((*sorted(v)))

-        word, page = input().split() -        page = int(page) +        data = input().split() -    d[word] = [page] if word not in d else d[word] + [page] -for word, pages in sorted(d.items()): -    print(word) -    print((*sorted(pages))) +    word = data[0] +    number = int(data[1]) +    if word in d: +        d[word].append(number) +    else: +        d[word] = [number] +for k, v in sorted(list(d.items()), key=lambda x: x[0]): +    print(k) +    print((*sorted(v)))