Problem A Tree Recovery Little Matija liked playing with binary trees very much. His favorite game was constructing randomly looking binary trees with capital letters in the nodes. This is an example of one of his creations: D / \ / \ B E / \ \ / \ \ A C G / / F To record his trees for future generations, he wrote down two strings for each tree: an inorder traversal (left subtree, root, right subtree) and a »leaves-first« order traversal (the data in all leaves are printed in left-to-right order, then the leaves are removed and the remaining tree is traversed in the same way). A leaf in a tree is a node with no descendants. For the tree drawn above the inorder traversal is ABCDEFG and the »leaves-first« order traversal is ACFBGED. Now, years later, looking again at the strings, he realized that reconstructing the trees was indeed possible, but only because he never had used the same letter twice in the same tree. However, doing the reconstruction by hand, soon turned out to be tedious. So now he asks you to write a program that does the job for him! Input Specification – a.in The input file will contain one or more test cases. Each test case consists of one line containing two strings, representing the inorder traversal and »leaves-first« order traversal of a binary tree. Both strings consist of unique capital letters (thus they are not longer than 26 characters). Input is terminated by end of file. Output Specification – a.out For each test case print one line containing the tree's level-order traversal (the data in all nodes at a given level are printed in left-to-right order and all nodes in level k are printed before all nodes at level k+1). Sample Input ABCDEFG ACFBGED CBAD CDAB Expected Output DBEACGF BCAD Problem B Connecting Paths “PATH” is a game played by two players on an N by N board, where N is a positive integer. (If N = 8, the board looks like a chess board.) Two players “WHITE” and “BLACK” compete in the game to build a path of pieces played on the board from the player’s “home” edge to the player’s “target” edge, opposite the home edge. WHITE uses white pieces and BLACK uses black pieces. For this problem you will play the “referee” for the game, analyzing boards contain- ing black and white pieces to determine whether either of the players has won the game or if one of the players can win by placing one of their pieces in an unfilled po- sition. WHITE’s turn is next. A representation of a board on paper (and in a computer) is an N x N matrix of chara- cters 'W', 'B', and 'U'; where 'W' represents white pieces, 'B' represents black pieces, and 'U' represents unfilled positions on the board. When we view a matrix representation of the board on paper, WHITE’s home edge is the left edge of the board (the first column), and WHITE’s target edge is the right edge (the last column). BLACK’s home edge is the top edge of the board (the first row), and BLACK’s target edge is the bottom edge (the last row). Thus WHITE wants to build a path from left to right, and BLACK wants to build a path from top to bottom. Two locations on the board are adjacent if one is immediately to the left, to the right above, or below the other. Thus an interior location on the board is adjacent to four other locations. For N>1, corner locations each have two adjacent locations, and for N>2, other border locations have three adjacent locations. A path is a sequence of distinct positions on the board, L0, L1,…, Lk, such that each pair Li and Li+1 are adjacent for i=0,…,k-1. A winning path for a player is a path L0, L1,…, Lk filled with the player’s pieces such that L0 is a position on the player’s home edge and Lk is a position on the player’s target edge. It is clear that if one player has a winning path then the other player is blocked from having a winning path. Thus if all the squares contain pieces, either there are no winning paths or exactly one of the players has at least one winning path. Input Specification – b.in Input is a series of game board data sets. Each set begins with a line containing an integer specifying the size N, 0