#!/bin/python3 import sys def findShortestPath(move_count, path, cur_pos, end_pos, moves): if cur_pos == end_pos: return move_count, path else: # determine direction, decide move direction = [x - y for x, y in zip(end_pos, cur_pos)] move = '' if direction[0] < 0: # upwards if direction[1] <= 0: # leftwards move += 'UL' else: # rightwards move += 'UR' elif direction[0] > 0: # downwards if direction[1] >= 0: # rightwards move += 'LR' else: # leftwards move += 'LL' else: # no vertical movement if direction[1] > 0: # rightwards move += 'R' else: # leftwards move += 'L' # update current position cur_pos = [x + y for x, y in zip(cur_pos, moves.get(move))] # update path path += (move + ' ') # update move_count move_count += 1 # call findShortestPath with updated variables return findShortestPath(move_count, path, cur_pos, end_pos, moves) def printShortestPath(n, i_start, j_start, i_end, j_end): # Print the distance along with the sequence of moves. i_dist = i_end - i_start if (i_dist % 2 != 0): print('Impossible') else: movements = ['UL', 'UR', 'R', 'LR', 'LL', 'L'] move_values = [[-2,-1], [-2,1], [0,2], [2,1], [2,-1], [0,-2]] moves = {x: y for x, y in zip(movements, move_values)} cur_pos = [i_start, j_start] end_pos = [i_end, j_end] move_count = 0 path = '' move_count, path = findShortestPath(move_count, path, cur_pos, end_pos, moves) print(move_count) print(path.rstrip()) if __name__ == "__main__": n = int(input().strip()) i_start, j_start, i_end, j_end = input().strip().split(' ') i_start, j_start, i_end, j_end = [int(i_start), int(j_start), int(i_end), int(j_end)] printShortestPath(n, i_start, j_start, i_end, j_end)