Problem F
Paths through the Hourglass
Input: Standard Input

Output: Standard Output

Time Limit: 2 Seconds

In the hourglass to the right a path is marked. A path always starts at the first row and ends at the last row. Each cell in the path (except the first) should be directly below to the left or right of the cell in the path in the previous row. The value of a path is the sum of the values in each cell in the path.

A path is described with an integer representing the starting point in the first row (the leftmost cell being 0) followed by a direction string containing the letters L and R, telling whether to go to the left or right. For instance, the path to the right is described as 2 RRRLLRRRLR.

Given the values of each cell in an hourglass as well as an integer S, calculate the number of distinct paths with value S. If at least one path exist, you should also print the path with the lowest starting point. If several such paths exist, select the one which has the lexicographically smallest direction string.

Input

The input contains several cases. Each case starts with a line containing two integers N and S (2≤N≤20, 0≤S<500), the number of cells in the first row of the hourglass and the desired sum. Next follows 2N-1 lines describing each row in the hourglass. Each line contains a space separated list of integers between 0 and 9 inclusive. The first of these lines will contain N integers, then N-1, ..., 2, 1, 2, ..., N-1, N.

The input will terminate with N=S=0. This case should not be processed. There will be less than 30 cases in the input.

 

 

Output

For each case, first output the number of distinct paths. If at least one path exist, output on the next line the description of the path mentioned above. If no path exist, output a blank line instead.

 

Sample Input                             Output for Sample Input

6 41

6 7 2 3 6 8

1 8 0 7 1

2 6 5 7

3 1 0

7 6

8

8 8

6 5 3

9 5 9 5

6 4 4 1 3

2 6 9 4 3 8

2 7

3 1

2

3 5

5 26

2 8 7 2 5

3 6 0 2

1 3 4

2 5

3

7 2

2 9 3

1 0 4 4

4 8 7 2 3

0 0

 

1

2 RRRLLRRRLR

0

 

5

2 RLLRRRLR

 


Problemsetter: Jimmy Mårdell, Member of Elite Problemsetters' Panel