#!/bin/python3 #!/bin/python3 import sys from collections import OrderedDict from operator import add ds = ['UL', 'UR', 'R', 'LR', 'LL', 'L'] dirs = [('UL', (-1,-2)), ('UR', (1,-2)), ('R', (2,0)), ('LR', (1, 2)), ('LL', (-1,2)), ('L', (-2,0))] def dist(p1,p2): return (abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])) def nextStep(pos, dest): best = None currdist = dist(pos, dest) if (currdist == 0): return ('Done') mindist = None minpos = None for i in dirs: newpos = list(map(add, pos, i[1])) newdist = dist(newpos, dest) print ('{}, {}, {:}, {}, {}, {}'.format(pos, dest, currdist, i, newpos, newdist), file=sys.stderr) if mindist is None or mindist > newdist: mindist = newdist minpos = newpos best = i print ("best: {}, [{}] -> [{}], dist:{} -> {}".format(best, pos, minpos, currdist, mindist), file=sys.stderr) if (mindist > currdist): print ('Got further: Abort', file=sys.stderr) best = None if (mindist == currdist): print ('No closer: Abort', file=sys.stderr) best = None return best def printShortestPath(n, i_start, j_start, i_end, j_end): pos = (j_start, i_start) dest = (j_end, i_end) steps = [] while True: bestMove = nextStep (pos, dest) if bestMove is None: print ('Impossible') return elif bestMove == 'Done': break else: steps.append(bestMove) pos = list(map(add, pos, bestMove[1])) print (len(steps)) #broken print (' '.join(s[0] for s in steps)) steps = sorted(steps, key=lambda x: ds.index(x[0])) print (' '.join(s[0] for s in steps)) 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)] printShortestPath(n, i_start, j_start, i_end, j_end)