import time t0 = time.time() import sys from queue import * class cell: def __init__(self , x1, y1, dis , p , m ,tx ,ty): self.x = x1 self.y = y1 self.dist = dis self.prev = p self.move = m self.distdiffx = tx self.distdiffy = ty def isInside( x , y , n): if (x>= 1 and x <= n) and (y >=1 and y<= n): return True else: return False def printShortestPath(n,starti,startj,desti,destj): visit = [[False] * (n+1) for _ in range(n+1)] #dy = [-1,1,2,-1,1,-2] #dx=[-2,-2,0,2,2,0] #mov=['UL','UR','R','LR','LL','L'] if destj - startj > 0 and desti - starti > 0: dy = [2,-1] dx=[0,2] mov=['R','LR'] elif destj - startj < 0 and desti - starti <0 : dy = [-1,-2] dx=[-2,0] mov=['UL','L'] elif destj - startj > 0 and desti - starti <0: dy = [1,2] dx=[-2,0] mov=['UR','R'] elif destj - startj <0 and desti - starti > 0: dy = [1,-2] dx=[2,0] mov=['LL','L'] elif destj - startj == 0 and desti > starti : dy = [-1,1] dx=[2,2] mov=['LR','LL'] elif destj - startj == 0 and desti < starti: dy = [-1,1] dx=[-2,-2] mov=['UL','UR'] elif destj < startj and desti == starti: dy = [-1,1,-2] dx=[-2,2,0] mov=['UL','LL','L'] else: dy = [1,2,-1] dx=[-2,0,2] mov=['UR','R','LR'] q = Queue() q.put(cell(starti+1,startj+1,0,None , None ,abs(desti - starti),abs(destj - startj) )) #visit[start[0]][start[1]] = True while q.qsize() > 0: t2 = time.time() if t2-t0 > 8 : break currentcell = q.get() visit[currentcell.x][currentcell.y] = True #currentcell.distdiffx = abs(desti - currentcell.x) #currentcell.distdiffy = abs(destj - currentcell.y) #print("%d %d %d %d "%(currentcell.x,currentcell.y,currentcell.distdiffx,currentcell.distdiffy)) if currentcell.x == desti+1 and currentcell.y == destj+1: print(currentcell.dist) movement=[] tempcell = currentcell while tempcell.prev != None : movement.append(tempcell.move) tempcell = tempcell.prev movement.reverse() for mo in movement: print(mo,end=" ") return True for i in range(len(dx)) : xt = currentcell.x + dx[i] yt = currentcell.y + dy[i] temptardiffx = abs(desti-xt) temptardiffy = abs(destj-yt) if isInside(xt,yt,n) and not visit[xt][yt] and temptardiffx - currentcell.distdiffx < 2 and temptardiffy - currentcell.distdiffy < 2: #print("%d %d %d %d "%(xt,yt,temptardiffx,temptardiffy)) q.put(cell(xt,yt,currentcell.dist +1,currentcell,mov[i],temptardiffx , temptardiffy)) return False 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)] if(not printShortestPath(n, i_start, j_start, i_end, j_end)): print("Impossible")