#!/usr/bin/env python

import codecs
import sys

codes = []
tags = []

out = codecs.getwriter('UTF-8')(sys.stdout)

def transform(char):
    if char == '\n':
        return ' '
    else:
        return char

for line in sys.stdin:
    line = line.rstrip()
    if not line:
        out.write('%s\n' % ''.join(map(transform, map(unichr, codes))))
        out.write('%s\n' % ''.join(tags))
        codes = []
        tags = []
    else:
        code, tag = line.split()
        code = int(code)
        codes.append(code)
        tags.append(tag)
