#!/bin/python import sys from collections import deque def onBoard(x, y, n): m1 = 0 <= x <= n-1 m2 = 0 <= y <= n-1 return m1 and m2 pred = dict() def bfs(src, des): L = [(-1, -2), (1, -2), (2, 0), (1, 2), (-1, 2), (-2, 0)] Q = deque() discovered = set() discovered.add(src) Q.appendleft(src) while Q: #print Q s = Q.pop() y, x = s for elem in L: dx, dy = elem if (y+dy, x+dx) == des: pred[des] = s #print "Here" return if onBoard(x+dx, y+dy, n) and (y+dy, x+dx) not in discovered: pred[(y+dy, x+dx)] = s Q.appendleft((y+dy, x+dx)) discovered.add((y+dy, x+dx)) return def printShortestPath(n, i_start, j_start, i_end, j_end): # Print the distance along with the sequence of moves. #L = [(-1, -1), (1, -1), (1, 0), (1, 1), (-1, 1), (-1, 0)] L = [(-1, -2), (1, -2), (2, 0), (1, 2), (-1, 2), (-2, 0)] A = ['UL', 'UR', 'R', 'LR', 'LL', 'L'] D = dict(zip(L, A)) sdy = (i_end - i_start) sdx = (j_end - j_start) dy = abs(i_end - i_start) dx = abs(j_end - j_start) if not ((dy % 2 == 0) and ((dy/2)%2) == dx % 2): print 'Impossible' return src = (i_start, j_start) des = (i_end, j_end) pred[src] = None bfs(src, des) #print pred #print des in pred result = '' start = des moves = [] while start != src: #print start yd, xd = start ys, xs = pred[start] move = (xd-xs, yd-ys) moves.append(move) start = pred[start] print len(moves) N = len(moves) for j in range(N-1, -1, -1): move = moves[j] result += D[move] + ' ' print result if __name__ == "__main__": n = int(raw_input().strip()) i_start, j_start, i_end, j_end = raw_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)