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 //////////////////// function printShortestPath(n, i_start, j_start, i_end, j_end) { // Print the distance along with the sequence of moves. const rowsDiff = i_start - i_end; const colsDiff = j_start - j_end; // First deny all impossible positions const imposible1 = rowsDiff % 2 !== 0; const imposible2 = (rowsDiff / 2) % 2 === 1 && colsDiff % 2 == 0; const imposible3 = (rowsDiff / 2) % 2 === 0 && colsDiff % 2 == 1; if (imposible1 || imposible2 || imposible3) { console.log('Impossible'); return; } const path = []; const step = (direction, position) => { switch (direction) { case 'L': position.j -= 2; break; case 'R': position.j += 2; break; case 'UL': position.i -= 2; position.j -= 1; break; case 'UR': position.i -= 2; position.j += 1; break; case 'LL': position.i += 2; position.j -= 1; break; case 'LR': position.i += 2; position.j += 1; break; } return position; } let position = {i: i_start, j: j_start}; const done = position => (i_end - position.i) === 0 && (j_end - position.j) === 0; while (!done(position)) { let direction = ''; if (position.i - i_end > 0) { // Move UP direction += 'U'; } else if (position.i - i_end) { // Move Down direction += 'L'; } if (position.j - j_end > 0) { // Move Left direction += 'L'; } else if (position.j - j_end < 0) { direction += 'R'; } else { direction += 'R'; } path.push(direction); position = step(direction, position); } console.log(path.length); console.log(path.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); }