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))))))
aW1wb3J0IGNvbGxlY3Rpb25zCgoKZGVmIHlvYmEoYywgcywgcGF0aD0oKSk6CgogICAgaWYgbm90IHM6CgogICAgICAgIHlpZWxkIHBhdGgKCiAgICBpZiBpc2luc3RhbmNlKGMsIHN0cik6CgogICAgICAgIGMgPSBjb2xsZWN0aW9ucy5Db3VudGVyKHN0ci5zcGxpdChjKSkKCiAgICBmb3Igd29yZCBpbiBzb3J0ZWQoYywga2V5PWxlbiwgcmV2ZXJzZT1UcnVlKToKCiAgICAgICAgaGVhZCwgdGFpbCA9IHNbOmxlbih3b3JkKV0sIHNbbGVuKHdvcmQpOl0KICAgICAgICBpZiBzb3J0ZWQod29yZCkgPT0gc29ydGVkKGhlYWQpOgoKICAgICAgICAgICAgZm9yIHJlcyBpbiB5b2JhKGMgLSBjb2xsZWN0aW9ucy5Db3VudGVyKCoqe3dvcmQ6IDF9KSwgdGFpbCwgcGF0aCArICgod29yZCwgaGVhZCksKSk6CiAgICAgICAgICAgIAkKICAgICAgICAgICAgCXlpZWxkIHJlcwoKCmEsIGIgPSBpbnB1dCgpLCBpbnB1dCgpCnByaW50KCJcbiIuam9pbihtYXAoIiAiLmpvaW4sIHppcCgqbmV4dCh5b2JhKGEsIGIpKSkpKSkK