#!/bin/python3 import sys result = "" count = -1 def euclideanDistance(x1,y1,x2,y2): x1 = (x1-x2) y1 = (y1-y2) return ( (x1*x1)+(y1*y1) )*(0.5) def printShortestPath(n, i_start, j_start, i_end, j_end): # Print the distance along with the sequence of moves. global result global count #print("=================== ITERATION ======================") dist = euclideanDistance(i_start-2, j_start-1, i_end, j_end) # UL #print("UL = "+str(temp)) a = i_start-2 b = j_start-1 move = "UL" temp = euclideanDistance(i_start-2, j_start+1, i_end, j_end) # UR #print("UR = "+str(temp)) if dist>temp: dist = temp move = "UR" a = i_start-2 b = j_start+1 temp = euclideanDistance(i_start, j_start+2, i_end, j_end) # R #print("R = "+str(temp)) if dist>temp: dist = temp move = "R" a = i_start b = j_start+2 temp = euclideanDistance(i_start+2, j_start+1, i_end, j_end) # LR #print("LR = "+str(temp)) if dist>temp: dist = temp move = "LR" a = i_start+2 b = j_start+1 temp = euclideanDistance(i_start+2, j_start-1, i_end, j_end) # LL #print("LL = "+str(temp)) if dist>temp: dist = temp move = "LL" a = i_start+2 b = j_start-1 temp = euclideanDistance(i_start, j_start-2, i_end, j_end) # L #print("L = "+str(dist)) if dist>temp: dist = temp a = i_start b = j_start-2 move = "L" if count==-1: count = 1 result += move else: result += " "+move i_start = a j_start = b #print("("+str(a)+","+str(b)+")") if a>=n or b>=n: result = "Impossible" count = -1 return; elif a<0 or b<0: result = "Impossible" count = -1 return; elif i_start==i_end and j_start==j_end: return; else: count += 1 printShortestPath(n, i_start, j_start, i_end, j_end) return; 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) if count==-1: print(result) else: print(str(count)+"\n"+result)