#!/bin/python3 import sys from collections import defaultdict def printShortestPath(graph, start, end, path=[]): # Print the distance along with the sequence of moves. path = path + [start] if start == end: return path shortest = None for node in graph[start]: if node not in path: newpath = printShortestPath(graph, node, end, path) if newpath: if not shortest or len(newpath) < len(shortest): shortest = newpath return shortest 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)] start = (i_start, j_start) end = (i_end, j_end) connections = [] d = defaultdict(list) directions = [(-2, -1), (-2, 1), (0, 2), (2, 1), (2, -1), (0, -2)] input_list = [[(j, i) for i in range(n)] for j in range(n)] for i in range(0, len(input_list)): for j in range(0, len(input_list)): for x, y in directions: if (i+x >= 0 and i+x < len(input_list) and j+y >= 0 and j+y < len(input_list)): pair = (input_list[i][j], input_list[i+x][j+y]) connections.append(pair) for k, v in connections: d[k].append(v) graph = dict(d.items()) shortest = printShortestPath(graph, start, end) flow = [] if shortest == None: print("Impossible") else: print(len(shortest) - 1) for i in range(len(shortest)): if i != len(shortest) - 1: if (shortest[i][0] - 2, shortest[i][1] - 1) == shortest[i+1]: flow.append("UL") elif (shortest[i][0] - 2, shortest[i][1] + 1) == shortest[i+1]: flow.append("UR") elif (shortest[i][0], shortest[i][1] + 2) == shortest[i+1]: flow.append("R") elif (shortest[i][0] + 2, shortest[i][1] + 1) == shortest[i+1]: flow.append("LR") elif (shortest[i][0] + 2, shortest[i][1] - 1) == shortest[i+1]: flow.append("LL") elif (shortest[i][0], shortest[i][1] - 2) == shortest[i+1]: flow.append("L") print(" ".join(flow))