#!/bin/python3 import sys # UL, UR, R, LR, LL, L def printShortestPath(n, i_start, j_start, i_end, j_end): moveNames = ["UL ", "UR ", "R ", "LR ", "LL ", "L "] moves = [(-2, -1), (-2, 1), (0, 2), (2, 1), (2, -1), (0, -2)] moveCounts = [[-1 for i in range(n)] for j in range(n)] currCount = 0 moveCounts[i_end][j_end] = 0 currLocs = [(i_end, j_end)] while(len(currLocs) > 0): currCount += 1 nextLocs = set() for i, j in currLocs: for iDiff, jDiff in moves: newI = i + iDiff newJ = j + jDiff if(newI >= 0 and newI < n and newJ >= 0 and newJ < n and moveCounts[newI][newJ] == -1): nextLocs.add((newI, newJ)) moveCounts[newI][newJ] = currCount currLocs = nextLocs if(moveCounts[i_start][j_start] == -1): print("Impossible") else: moveCount = moveCounts[i_start][j_start] moveList = "" i = i_start j = j_start while(i != i_end or j != j_end): for index in range(len(moves)): newI = i + moves[index][0] newJ = j + moves[index][1] if(newI >= 0 and newI < n and newJ >= 0 and newJ < n and moveCounts[newI][newJ] == moveCount - 1): i = newI j = newJ moveList += moveNames[index] moveCount -= 1 break print(moveCounts[i_start][j_start]) print(moveList) 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)