Tobby and the LED display

Tobby got his first job! Being a lazy puppy, the work that he has found is not very demanding and it consists of observing a LED display during T minutes and reporting the status of the LED display once this time runs out. The LED display is capable of displaying N characters and the text can move in two directions, Left or Right. In every minute the character that occupies the ith position moves to the (i − 1)-th or (i + 1)-th position, depending on the direction in which the text moves in the LED display. The LED display works in a circular way, therefore, if the character that occupies the i = 1 position moves to the left its new position will be i = N, moreover, if the character that occupies the i = N position moves to the right its new position will be i = 1. i.e. if Tobby got the board shown below where N = 10, T = 3 and the direction in which the text moves is Right, the following will happen: Minute 0 +-------------------+ | | | |T|o|b|b|y|!|!| +-------------------+ Minute 1 +-------------------+ |!| | | |T|o|b|b|y|!| +-------------------+ Minute 2 +-------------------+ |!|!| | | |T|o|b|b|y| +-------------------+ After 3 minutes, Tobby should report the board shown below. +-------------------+ |y|!|!| | | |T|o|b|b| +-------------------+ As it has been said, Tobby is very lazy and wont spends his time on this boring task, that’s why he is willing to give you a bone from his first payment as reward :). Input The input consists of several test cases and must be read until EOF. The first line of each test case contains two integers N, T (1 ≤ N ≤ 50000, 1 ≤ T ≤ 1014), and one character D (D = ‘L’ or D = ‘R’), here N indicates the number of characters that the LED display can show, T shows the number of minutes that Tobby must wait to report the LED display state and D is the direction in which the LED display will work L = Left and R = Right. Then, there will be 3 lines and each one has (2∗N) + 1 characters. The first and third line are the upper edge and the lower edge respectively of the LED display, The second line shows the initial content of the LED display.

2/2 Output For each test case the output must consist of 3 lines each one will have (2∗N ) + 1 characters. The first and third line are the upper edge and the lower edge respectively of the LED display and the second one will show the LED display state after T minutes. Sample Input 10 3 R +–––––––––––––––––––+ | | | |T|o|b|b|y|!|!| +–––––––––––––––––––+ Sample Output +–––––––––––––––––––+ |y|!|!| | | |T|o|b|b| +–––––––––––––––––––+