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 //////////////////// let min = Infinity; let sPath = null; function printShortestPath(n, i_start, j_start, i_end, j_end, path=[], count=0) { // Print the distance along with the sequence of moves. //console.log(i_start, j_start, i_end, j_end) if (i_start === i_end && j_start === j_end) { if (count < min) { min = count; sPath = path.slice(); //console.log('new min: ', min, ' sPath:', sPath) } } if (validate(n, i_start, j_start, i_end, j_end)) { const ds = getDis(i_start, j_start, i_end, j_end); for (let i = 0; i < moves.length; i++) { const move = moves[i]; //console.log('next move: ', move) const newI = i_start + mvs[move].i; const newJ = j_start + mvs[move].j; const newDs = getDis(newI, newJ, i_end, j_end); //console.log(i_start, j_start, 'newI: ', newI, ' newJ:', newJ, 'newDs: ', newDs, path) if (newDs < ds) { count++; path.push(move); printShortestPath(n, newI, newJ, i_end, j_end, path, count) path.pop(); count--; } } } } 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); if (sPath) { console.log(min); console.log(sPath.join(' ')); } else { console.log('Impossible'); } } function getDis(i1, j1, i2, j2) { return Math.abs(i1 - i2) + Math.abs(j1 - j2); } function validate(n, i_start, j_start, i_end, j_end) { if (i_start < 0 || j_start < 0 || i_end < 0 || j_end < 0) return false; if (i_start >= n || j_start >= n || i_end >= n || j_end >= n) return false; const di = Math.abs(i_start - i_end); const dj = Math.abs(j_start - j_end); if (di % 2 === 0) { return (dj - di / 2) % 2 === 0; } else { return false; } } function validateOld(n, i_start, j_start, i_end, j_end) { if (i_start < 0 || j_start < 0 || i_end < 0 || j_end < 0) return false; if (i_start >= n || j_start >= n || i_end >= n || j_end >= n) return false; const di = Math.abs(i_start - i_end); return true; } const moves = ['UL', 'UR', 'R', 'LR', 'LL', 'L']; const mvs = { 'UL': { i: -2, j: -1 }, 'UR': { i: -2, j: 1 }, 'R': { i: 0, j: 2 }, 'LR': { i: 2, j: 1 }, 'LL': { i: 2, j: -1 }, 'L': { i: 0, j: -2 } }