#!/bin/python3 import sys def is_valid(n, i, j): return 0 <= i and i < n and 0 <= j and j < n def get_move(n, i_start, j_start, i_end, j_end, step): i, j = [i_start, j_start] step_length = len(step) if step_length == 1: if step == "L": j-=2 else: j+=2 else: if step[0] == "U": i-=2 else: i+=2 if step[1] == "L": j-=1 else: j+=1 if is_valid(n, i, j): return [i, j, abs(i - i_end) + abs(j - j_end)] else: return -1 def move(n, i_start, j_start, i_end, j_end, step_collector): steps = ["UL", "UR", "R", "LR", "LL", "L"] min_step = "" min_cost = 500 for step in steps: the_move = get_move(n, i_start, j_start, i_end, j_end, step) if the_move != -1: if the_move[2] < min_cost: min_cost = the_move[2] min_step = step i = the_move[0] j = the_move[1] step_collector.append(min_step) if i != i_end or j != j_end: move(n, i, j, i_end, j_end, step_collector) def printShortestPath(n, i_start, j_start, i_end, j_end): i_diff = abs(i_start - i_end) j_diff = abs(j_start - j_end) is_imp = False if i_diff&1 == 1: is_imp = True if (i_diff>>1)&1 == 0: if j_diff&1 == 1: is_imp = True else: if j_diff&1 != 1: is_imp = True if is_imp == True: print("Impossible") else: step_collector = [] move(n, i_start, j_start, i_end, j_end, step_collector) print(len(step_collector)) for step in step_collector: print(step, end = " ") 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)