#!/bin/python3 def can_move_right(i_start, j_start, i_end, j_end): i_diff = abs(i_start - i_end) q = i_diff // 2 return j_start + q - j_end <= -2 # UL, UR, R, LR, LL, L. all_moves = [] def print_shortest_path(n, i_start, j_start, i_end, j_end, m): if i_start == i_end and j_start == j_end: return m if abs(i_start-i_end) <= 1 and abs(j_start-j_end) <= 1: return "Impossible" if i_start - i_end > 0: # move up i_start -= 2 move = "" if j_start - j_end > 1: move = "UL" j_start -= 1 else: move = "UR" j_start += 1 m.append(move) return print_shortest_path(n, i_start, j_start, i_end, j_end, m) #if j_start - j_end < 1: if can_move_right(i_start, j_start, i_end, j_end): # move right m.append("R") return print_shortest_path(n, i_start, j_start+2, i_end, j_end, m) if i_start - i_end < 0 : # move down i_start += 2 move = "" if j_start - j_end < 1: move = "LR" j_start += 1 else: move = "LL" j_start -= 1 m.append(move) return print_shortest_path(n, i_start, j_start, i_end, j_end, m) if j_start - j_end > 1: # move left m.append("L") return print_shortest_path(n, i_start, j_start-2, i_end, j_end, m) def printShortestPath(n, i_start, j_start, i_end, j_end): moves = print_shortest_path(n, i_start, j_start, i_end, j_end, list()) if moves == "Impossible": print("Impossible") else: print(len(moves)) print(" ".join(moves)) 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)