#!/bin/python import sys def is_valid(i, j, n): return True if 0 <= i <= n and 0 <= j <= n else False # UL, UR, R, LR, LL, L def calculateShortest(n, i_start, j_start, i_end, j_end, moves, places): recurse = True if i_start == i_end: if j_start == j_end: output = '' for move in moves: output += move + ' ' print len(moves) print output return elif j_start < j_end and is_valid(i_start - 2, j_start + 1, n): i_start -= 2 j_start += 1 moves.append('UR') elif j_start < j_end and is_valid(i_start, j_start + 2, n) and j_start + 2 <= j_end: j_start += 2 moves.append('R') elif j_start < j_end and is_valid(i_start + 2, j_start + 1, n): i_start += 2 j_start += 1 moves.append('LR') elif j_start > j_end and is_valid(i_start - 2, j_start - 1, n): i_start -= 2 j_start -= 1 moves.append('UL') elif j_start > j_end and is_valid(i_start, j_start + 2, n) and j_start - 2 >= j_end: j_start -= 2 moves.append('L') elif j_start < j_end and is_valid(i_start + 2, j_start - 1, n): i_start += 2 j_start -= 1 moves.append('LL') else: recurse = False if i_start < i_end: if (j_start == j_end and is_valid(i_start + 2, j_start + 1, n)) or \ (j_start < j_end and is_valid(i_start + 2, j_start + 1, n)): i_start += 2 j_start += 1 moves.append('LR') elif (j_start == j_end and is_valid(i_start + 2, j_start - 1, n)) or \ (j_start > j_end and is_valid(i_start + 2, j_start - 1, n)): i_start += 2 j_start -= 1 moves.append('LL') else: recurse = False if i_start > i_end: if (j_start == j_end and is_valid(i_start - 2, j_start - 1, n)) or \ (j_start > j_end and is_valid(i_start - 2, j_start - 1, n)): i_start -= 2 j_start -= 1 moves.append('UL') elif (j_start == j_end and is_valid(i_start - 2, j_start + 1, n)) or \ (j_start < j_end and is_valid(i_start - 2, j_start + 1, n)): i_start -= 2 j_start += 1 moves.append('UR') else: recurse = False place = '%s%s' % (str(i_start), str(j_start)) if place in places: print "Impossible" return else: places.append(place) if recurse: calculateShortest(n, i_start, j_start, i_end, j_end, moves, places) else: print "Impossible" return def printShortestPath(n, i_start, j_start, i_end, j_end): # Print the distance along with the sequence of moves. moves = [] places = [] calculateShortest(n, i_start, j_start, i_end, j_end, moves, places) 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)