Задачі
Flipper
Flipper
Little Bobby Roberts (son of Big Bob, of Problem G) plays this solitaire memory game called Flipper. He starts with \textit{\textbf{n}} cards, numbered \textbf{1} through \textit{\textbf{n}}, and lays them out in a row with the cards in order left-to-right. (Card \textbf{1} is on the far left; card \textit{\textbf{n}} is on the far right.) Some cards are face up and some are face down. Bobby then performs \textit{\textbf{n}} - \textbf{1} flips --- either right flips or left flips. In a right flip he takes the pile to the far right and flips it over onto the card to its immediate left. For example, if the rightmost pile has cards \textbf{A}, \textbf{B}, \textbf{C} (from top to bottom) and card \textbf{D} is to the immediate left, then flipping the pile over onto card \textbf{D} would result in a pile of \textbf{4} cards: \textbf{C}, \textbf{B}, \textbf{A}, \textbf{D} (from top to bottom). A left flip is analogous.
The very last flip performed will result in one pile of cards --- some face up, some face down. For example, suppose Bobby deals out \textbf{5} cards (numbered \textbf{1} through \textbf{5}) with cards \textbf{1} through \textbf{3} initially face up and cards \textbf{4} and \textbf{5} initially face down. If Bobby performs \textbf{2} right flips, then \textbf{2} left flips, the pile will be (from top to bottom) a face down \textbf{2}, a face up \textbf{1}, a face up \textbf{4}, a face down \textbf{5}, and a face up \textbf{3}.
Now Bobby is very sharp and you can ask him what card is in any position and he can tell you!!! You will write a program that matches Bobby’s amazing feat.
\InputFile
Each test case will consist of \textbf{4} lines. The first line will be a positive integer \textit{\textbf{n}} (\textbf{2} ≤ \textit{\textbf{n}} ≤ \textbf{100}) which is the number of cards laid out. The second line will be a string of \textit{\textbf{n}} characters. A character \textbf{U} indicates the corresponding card is dealt face up and a character \textbf{D} indicates the card is face down. The third line is a string of \textit{\textbf{n}} - \textbf{1} characters indicating the order of the flips Bobby performs. Each character is either \textbf{R}, indicating a right flip, or \textbf{L}, indicating a left flip. The fourth line is of the form \textit{\textbf{m}}\textit{ }\textit{\textbf{q_1}}\textit{ }\textit{\textbf{q_2}}\textit{ ... }\textit{\textbf{q_m}}, where \textit{\textbf{m}} is a positive integer and \textbf{1} ≤ \textit{\textbf{q_i}} ≤ \textit{\textbf{n}}. Each \textit{\textbf{q_i}} is a query on a position of a card in the pile (\textbf{1}\textit{\textbf{ }}being the top card, \textit{\textbf{n}} being the bottom card). A line containing \textbf{0} indicates end of input.
\OutputFile
Each test case should generate \textit{\textbf{m}} + \textbf{1} lines of output. The first line is of the form
\textbf{Pile }\textit{\textbf{t}}
where \textit{\textbf{t}} is the number of the test case (starting at \textbf{1}). Each of the next \textit{\textbf{m}} lines should be of the form
\textbf{Card }\textit{\textbf{q_i}}\textbf{ is a face up }\textit{\textbf{k}}\textbf{.}
or
\textbf{Card }\textit{\textbf{q_i}}\textbf{ is a face down }\textit{\textbf{k}}\textbf{.}
accordingly, for \textit{\textbf{i}} = \textbf{1}, ..., \textit{\textbf{m}}, where \textit{\textbf{k}} is the number of the card.
For instance, in the above example with \textbf{5} cards, if \textit{\textbf{q_i}} = 3, then the answer would be
\textbf{Card 3 is a face up 4.}
Вхідні дані #1
5 UUUDD RRLL 5 1 2 3 4 5 10 UUDDUUDDUU LLLRRRLRL 4 3 7 6 1 0
Вихідні дані #1
Pile 1 Card 1 is a face down 2. Card 2 is a face up 1. Card 3 is a face up 4. Card 4 is a face down 5. Card 5 is a face up 3. Pile 2 Card 3 is a face down 1. Card 7 is a face down 9. Card 6 is a face up 7. Card 1 is a face down 5.