#!/bin/python import sys import math def moveUL(n,i,j): # n max for validation (i,j) position i_new = i - 2 j_new = j - 1 if i_new < 0 or i_new >= n or j_new < 0 or j_new >= n: return None, None return (i_new, j_new) def moveUR(n,i,j): # n max for validation (i,j) position i_new = i - 2 j_new = j + 1 if i_new < 0 or i_new >= n or j_new < 0 or j_new >= n: return None, None return (i_new, j_new) def moveR(n,i,j): # n max for validation (i,j) position i_new = i j_new = j + 2 if i_new < 0 or i_new >= n or j_new < 0 or j_new >= n: return None, None return (i_new, j_new) def moveLR(n,i,j): # n max for validation (i,j) position i_new = i + 2 j_new = j + 1 if i_new < 0 or i_new >= n or j_new < 0 or j_new >= n: return None, None return (i_new, j_new) def moveLL(n,i,j): # n max for validation (i,j) position i_new = i + 2 j_new = j - 1 if i_new < 0 or i_new >= n or j_new < 0 or j_new >= n: return None, None return (i_new, j_new) def moveL(n,i,j): # n max for validation (i,j) position i_new = i j_new = j - 2 if i_new < 0 or i_new >= n or j_new < 0 or j_new >= n: return None, None return (i_new, j_new) def correct_way(i_old, j_old,i_new, j_new, i_end, j_end): # if abs(i_old - i_end) > abs(i_new - i_end) or abs(j_old - j_end) > abs(j_new - j_end): if math.sqrt(abs(i_old - i_end)**2 + abs(j_old - j_end)**2)> math.sqrt(abs(i_new - i_end)**2 + abs(j_new - j_end)**2): # print 'correct' return True # print 'wrong' return False def is_finished(i_start, j_start, i_end, j_end): if i_start == i_end and j_start == j_end: # print 'is batata done' return True # print 'is batata false' return False def print_path(path_list): print len(path_list) for e in path_list: print "%s" %e, def save_shortest(path): global SHORTEST_PATH if not SHORTEST_PATH: for e in path: SHORTEST_PATH.append(e) else: if len(SHORTEST_PATH) > len(path): SHORTEST_PATH = [] for e in path: SHORTEST_PATH.append(e) def search(n, i_start, j_start, i_end, j_end, path_list=[]): # print 'search ', n, i_start, j_start, i_end, j_end, path_list if is_finished(i_start, j_start, i_end, j_end): #save_shortest(path_list) #return path_list # print 'done' print_path(path_list) raise Exception("Done") # print 'moveUL' i,j = moveUL(n,i_start, j_start) if i is not None and j is not None: if correct_way(i_start, j_start,i ,j, i_end, j_end): path_list.append('UL') l = search(n,i ,j, i_end, j_end, path_list) if l: del path_list[-1] return path_list else: return None # print 'moveUR' i,j = moveUR(n,i_start, j_start) if i is not None and j is not None: if correct_way(i_start, j_start,i ,j, i_end, j_end): path_list.append('UR') l = search(n,i ,j, i_end, j_end, path_list) if l: del path_list[-1] return path_list else: return None i,j = moveR(n,i_start, j_start) if i is not None and j is not None: if correct_way(i_start, j_start,i ,j, i_end, j_end): path_list.append('R') l = search(n,i ,j, i_end, j_end, path_list) if l: del path_list[-1] return path_list else: return None # print 'moveLR' i,j = moveLR(n,i_start, j_start) if i is not None and j is not None: if correct_way(i_start, j_start,i ,j, i_end, j_end): path_list.append('LR') l = search(n,i ,j, i_end, j_end, path_list) if l: del path_list[-1] return path_list else: return None # print 'moveLL' i,j = moveLL(n,i_start, j_start) if i is not None and j is not None: if correct_way(i_start, j_start,i ,j, i_end, j_end): path_list.append('LL') l = search(n,i ,j, i_end, j_end, path_list) if l: del path_list[-1] return path_list else: return None # print 'moveL' i,j = moveL(n,i_start, j_start) if i is not None and j is not None: if correct_way(i_start, j_start,i ,j, i_end, j_end): path_list.append('L') l = search(n,i ,j, i_end, j_end, path_list) if l: del path_list[-1] return path_list else: return None # print 'WTF' return None def printShortestPath(n, i_start, j_start, i_end, j_end): # print the distance along with the sequence of moves. try: l = search(n, i_start, j_start, i_end, j_end) #if l: # print_path(l) #else: print 'Impossible' except Exception as e: #print e pass if __name__ == "__main__": global SHORTEST_PATH SHORTEST_PATH = [] 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)