You have a set of cards laid out in an $n$ by $m$ grid. Each card is numbered, and some are face up while others are face down. You can collapse the grid into a single pile using a series of flips. Each flip is one of the following four types:
After a series of $n + m - 2$ flips, all the cards form a single pile, some face up and some face down. Determine the order of the face-up cards in this final pile.
Each test case starts with a line containing two positive integers $n$ and $m$, the number of rows and columns in the grid. The next $n$ lines each contain $m$ integers giving the cards' numbers and orientations. (The first line is the top row, and the first value in each line is the leftmost card.) A positive integer $k$ means card $k$ is at that location face up; a negative integer $-k$ means card $k$ is at that location face down ($k$ is never zero.)
After these $n$ lines comes one more line of $n + m - 2$ characters describing the flips to apply, each being T, B, L, or R for a top, bottom, left, or right flip. Every flip sequence is legal: you are never asked to perform more than $n - 1$ top-and-bottom flips or more than $m - 1$ left-and-right flips. The maximum value of $n$ and $m$ is $20$.
Input ends with a line containing two zeros.
For each test case, print the case number followed by the numbers of all face-up cards in the final pile, listed starting from the bottom of the pile, in the format shown below.
Case X: c1 c2 ...
If no card ends up face up, print only the case label (for example, Case 2:).