# valid moves priority = UL, UR, R, LR, LL, L moves_labels = ["UL", "UR", "R", "LR", "LL", "L"] moves = [(-2, -1), (-2, 1), (0, 2), (2, 1), (2, -1), (0, -2)] def move_to_next(pos, move): next_pos = (pos[0] + move[0], pos[1] + move[1]) return next_pos def is_valid_pos(pos, n): inside_x = 0 <= pos[1] <= n inside_y = 0 <= pos[0] <= n return inside_x and inside_y def is_destination(pos_a, pos_b): return pos_a == pos_b def printShortestPath(n, i_start, j_start, i_end, j_end): start = (i_start, j_start) end = (i_end, j_end) to_visit_from = [(start, [])] visited = set() for node_path in to_visit_from: node = node_path[0] path = node_path[1] if node in visited: continue if is_destination(node, end): final_path = ' '.join(path) print(len(path)) print(final_path) return visited.add(node) # check next nodes for i, m in enumerate(moves): next_position = move_to_next(node, m) if is_valid_pos(next_position, n): next_path = path.copy() next_path.append(moves_labels[i]) next_node_path = (next_position, next_path) to_visit_from.append(next_node_path) print('Impossible') 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)