{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in the nodes. \r\u003cbr\u003eThis is an example of one of her creations: \r\u003cbr\u003e\u003cpre\u003e\r\u003cbr\u003e D\r\u003cbr\u003e / \\\r\u003cbr\u003e / \\\r\u003cbr\u003e B E\r\u003cbr\u003e / \\ \\\r\u003cbr\u003e / \\ \\\r\u003cbr\u003e A C G\r\u003cbr\u003e /\r\u003cbr\u003e /\r\u003cbr\u003e F\r\u003cbr\u003e\u003c/pre\u003e\r\u003cbr\u003eTo record her trees for future generations, she wrote down two strings for each tree: a preorder traversal (root, left subtree, right subtree) and an inorder traversal (left subtree, root, right subtree). For the tree drawn above the preorder traversal is DBACEGF and the inorder traversal is ABCDEFG. \r\u003cbr\u003eShe thought that such a pair of strings would give enough information to reconstruct the tree later (but she never tried it). \r\u003cbr\u003e\r\u003cbr\u003eNow, years later, looking again at the strings, she realized that reconstructing the trees was indeed possible, but only because she never had used the same letter twice in the same tree. \r\u003cbr\u003eHowever, doing the reconstruction by hand, soon turned out to be tedious. \r\u003cbr\u003eSo now she asks you to write a program that does the job for her! \r\u003cbr\u003e\r\u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input will contain one or more test cases. \r\u003cbr\u003eEach test case consists of one line containing two strings preord and inord, representing the preorder traversal and inorder traversal of a binary tree. Both strings consist of unique capital letters. (Thus they are not longer than 26 characters.)\r\u003cbr\u003eInput is terminated by end of file. \r\u003cbr\u003e\r\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, recover Valentine\u0027s binary tree and print one line containing the tree\u0027s postorder traversal (left subtree, right subtree, root). "}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003eDBACEGF ABCDEFG\r\nBCAD CBAD\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eACBFGED\r\nCDAB\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}