BEANGAME - Help MR BEAN

no tags 

Mr. Bean loves to play games. For this he wastes lots of money so Mrs. Bean made a hurdle game for him. Now in the game we have 3 tracks and for moving up to next level he will have to cross some hurdles. Each time he changes the track he gets some drink to increase his energy level by that amount. The drink that he gets is the one which is in between the present track and the adjacent track and in the direction of movement (adjacent track may or may not be the track on which he is targeting to move). Now if at any moment his energy becomes negative his game will be over. So you have make him win this game with maximum energy being available with him at last. He will move in the form of 'L' and 'R' between adjacent tracks with 'L' making him move one step left of the present position and 'R' moving him right. Movement between different level will be separated by '-' and if there is no change of track between adjacent levels then print 'U' at its corresponding move .

Input

First line will have 3 integers Il, Ie, Ns where Il is the initial track on which he is standing, Ie is the initial energy he is having and Ns is the number of levels in the game. Then it would be followed by 5 lines where the first three will have the values of the hurdles present at each level on each track. Fourth line will have Ns-1 integers representing the energy obtained by him on drinking the energy drink between continuous levels between track 1 and 2 and similarly fifth line will have Ns-1 values for drinks between tracks 2 and 3.

Output

Print "DONE IT!" in first line and the steps taken by him in second line following the path which leads to maximum energy available with Mr. Bean beyond final track. If it is not possible print "GAME OVER!".

Constraints

Every integer, intermediate values will fit in 32-bit integer.

Example

Input:
1 6 5
3 2 9 16 3
4 0 7 26 1
1 7 3 30 9
8 19 8 3
10 3 6 4 Output: DONE IT!
RR-LL-RR-LL-R

hide comments
Mrs. Bean: 2014-05-17 00:28:20

@jain_aarushi pls check ur code for base test like this :-
1 0 5
3 2 9 16 3
4 0 7 26 1
1 7 3 30 9
8 19 8 3
10 3 6 4

GAME OVER!

Last edit: 2014-02-19 07:07:13

Added by:Mrs. Bean
Date:2012-12-17
Time limit:1s-2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own Problem