#!/bin/python import sys from Queue import Queue def make_step(desk, q, new_i, new_j, story, step_name, i_end, j_end): if new_i >= 0 and new_j >= 0 and new_i < len(desk) and new_j < len(desk): if new_i == i_end and new_j == j_end: # found path story.append(step_name) print(len(story)) print(" ".join(story)) return True else: if desk[new_i][new_j] is None or desk[new_i][new_j] > len(story) + 1: new_story = list(story) new_story.append(step_name) q.put((new_i, new_j, new_story)) desk[new_i][new_j] = len(new_story) return False def printShortestPath(n, i_start, j_start, i_end, j_end): desk =[] for i in range(n): desk.append([None] * n ) desk[i_start][j_start] = 0 q = Queue() q.put((i_start, j_start, [])) while not q.empty(): row, col, story = q.get() # UL, UR, R, LR, LL, L if make_step(desk, q, row - 2, col - 1, story, "UL", i_end, j_end): break if make_step(desk, q, row - 2, col + 1, story, "UR", i_end, j_end): break if make_step(desk, q, row, col + 2, story, "R", i_end, j_end): break if make_step(desk, q, row + 2, col + 1, story, "LR", i_end, j_end): break if make_step(desk, q, row + 2, col - 1, story, "LL", i_end, j_end): break if make_step(desk, q, row, col - 2, story, "L", i_end, j_end): break q.task_done() if q.empty(): print "Impossible" 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)