process.stdin.resume(); process.stdin.setEncoding('ascii'); var input_stdin = ""; var input_stdin_array = ""; var input_currentline = 0; process.stdin.on('data', function (data) { input_stdin += data; }); process.stdin.on('end', function () { input_stdin_array = input_stdin.split("\n"); main(); }); function readLine() { return input_stdin_array[input_currentline++]; } /////////////// ignore above this line //////////////////// // order of priority: UL, UR, R, LR, LL, L function nextMove(n, i_start, j_start, i_end, j_end) { const horizontalDiff = j_start - j_end; const horizontalAbs = Math.abs(horizontalDiff); const verticalDiff = i_start - i_end; const verticalAbs = Math.abs(verticalDiff); if ((verticalAbs === 0 && horizontalAbs % 2 !== 0) || verticalAbs % 2 !== 0) { return null; } if (horizontalAbs <= 2 && verticalAbs <= 2 && !((verticalAbs === 0 && horizontalAbs === 2) || (verticalAbs === 2 && horizontalAbs === 1))) { return null; } let action = ''; let i = i_start; let j = j_start; if (verticalDiff > 0) { action += 'U'; i -= 2; if (i < 0) { return null; } } else if (verticalDiff < 0) { action += 'L'; i += 2; if (i >= n) { return null; } } const horizontalIncrement = i === i_start ? 2 : 1; if (horizontalDiff < 0) { action += 'R'; j += horizontalIncrement; if (j >= n) { return null; } } else if (horizontalDiff > 0) { action += 'L'; j -= horizontalIncrement; if (j < 0) { return null; } } else if (i > i_start) { // move downwards if ((j + horizontalIncrement) < n) { // can move to the right action += 'R'; j += horizontalIncrement; } else { action += 'L'; j -= horizontalIncrement; } } else { // move upwards if ((j - horizontalIncrement) >= 0) { // can move to the left action += 'L'; j -= horizontalIncrement; } else { action += 'R'; j += horizontalIncrement; } } return {i, j, action}; } // order of priority: UL, UR, R, LR, LL, L const priorities = ['UL', 'UR', 'R', 'LR', 'LL', 'L']; function sortMoves(moves) { return moves.sort((a, b) => priorities.indexOf(a) - priorities.indexOf(b)); } function printShortestPath(n, i_start, j_start, i_end, j_end) { const moves = []; let move = nextMove(n, i_start, j_start, i_end, j_end); while (move !== null) { moves.push(move.action); if (move.i === i_end && move.j === j_end) { break; } move = nextMove(n, move.i, move.j, i_end, j_end); } if (!move) { return console.log('Impossible'); } console.log(moves.length); console.log(sortMoves(moves).join(' ')); } function main() { var n = parseInt(readLine()); var i_start_temp = readLine().split(' '); var i_start = parseInt(i_start_temp[0]); var j_start = parseInt(i_start_temp[1]); var i_end = parseInt(i_start_temp[2]); var j_end = parseInt(i_start_temp[3]); printShortestPath(n, i_start, j_start, i_end, j_end); }