import collections


def yoba(c, s, path=()):

    if not s:

        yield path

    if isinstance(c, str):

        c = collections.Counter(str.split(c))

    for word in sorted(c, key=len, reverse=True):

        head, tail = s[:len(word)], s[len(word):]
        if sorted(word) == sorted(head):

            for res in yoba(c - collections.Counter(**{word: 1}), tail, path + ((word, head),)):
            	
            	yield res


a, b = input(), input()
print("\n".join(map(" ".join, zip(*next(yoba(a, b))))))
