#!/bin/python3 import sys moves_possible = ["UL", "UR", "R", "LR", "LL", "L"] def moving(move, position): right = False if "R" in move: right = True position[1] = position[1]+1 else: position[1] = position[1]-1 if "U" in move: position[0] = position[0]-2 elif "L" in move: position[0] = position[0]+2 else: if "R" in move: position[1] = position[1]+1 else: position[1] = position[1]-1 return(position) def calc_y(a,b): diff = abs(a-b) if diff%2 == 1: return "impossible" return diff//2 def allowable_moves(current, destination): usable_moves = [] a,b = current[0],current[1] x,y = destination[0],destination[1] if bx: usable_moves.append("UR") elif ay: usable_moves.append("L") if a>x: usable_moves.append("UL") elif ax: usable_moves.extend(["UL","UR"]) return usable_moves def printShortestPath(n, i_start, j_start, i_end, j_end): # Print the distance along with the sequence of moves. return(1) 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)] allowed_movements = allowable_moves([i_start, j_start], [i_end, j_end]) moves_used= [] up_downs = calc_y(i_start,i_end) if up_downs == "impossible": print("Impossible") else: ups = [s for s in allowed_movements if "U" in s or "D" in s][0] for i in range(up_downs): moves_used.append(ups) [i_start,j_start] = moving(ups, [i_start,j_start]) left_rights = calc_y(j_start, j_end) if left_rights == "impossible": print("Impossible") else: if "L" in allowed_movements: for i in range(left_rights): moves_used.append("L") [i_start,j_start] = moving("L", [i_start,j_start]) elif "R" in allowed_movements: for i in range(left_rights): moves_used.append("R") moving("R", [i_start,j_start]) print(up_downs+left_rights) for i in moves_used: print(i,end=" ")