#!/bin/python3 import sys import queue def printShortestPath(n, i_start, j_start, i_end, j_end): # Print the distance along with the sequence of moves. cur_pos = (i_start, j_start) cur_row, cur_col = cur_pos cur_path = [] end = (i_end, j_end) movesList = [(-2, -1), (-2, 1), (0, 2), (2, 1), (2, -1), (0, -2)] seen = set() seen.add(cur_pos) q = queue.Queue() while cur_pos != end: for newMove in movesList: new_path = cur_path + [newMove] dRow, dCol = newMove new_row = cur_row + dRow new_col = cur_col + dCol new_pos = (new_row, new_col) if new_row >= 0 and new_col >= 0 and new_row < n and new_col < n and new_pos not in seen: if new_pos == end: printMoveNames(new_path) return q.put((new_pos, new_path)) seen.add(new_pos) if q.empty(): print("Impossible") cur_pos, cur_path = q.get() cur_row, cur_col = cur_pos print(0) def printMoveNames(moveList): moves = { (-2, -1): "UL", (-2, 1): "UR", (0, 2): "R", (2, 1): "LR", (2, -1): "LL", (0, -2): "L" } print(len(moveList)) moveNames = [] for move in moveList: moveNames.append(moves[move]) print(" ".join(moveNames)) 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)