#!/bin/python3 import sys def update_table(board, path, cells, i_old, j_old, i_new, j_new, current_l, move): board[i_new][j_new] = current_l cells.append((i_new, j_new)) path[(i_new, j_new)] = path[(i_old, j_old)].copy() path[(i_new, j_new)].append(move) def printShortestPath(n, i_start, j_start, i_end, j_end): # Print the distance along with the sequence of moves. moves_order = ['UpperLeft', 'UpperRight', 'Right', 'LowerRight', 'LowerLeft', 'Left'] board = [] for _ in range(n): board.append([-1] * n) board[i_start][j_start] = 0 path = {(i_start, j_start): []} current_l = 0 current_cells = [(i_start, j_start)] can_move = 1 while can_move: current_l += 1 can_move = 0 new_cells = [] for cell in current_cells: if cell[0] > 1: if cell[1] > 0 and board[cell[0] - 2][cell[1] - 1] < 0: update_table(board, path, new_cells, cell[0], cell[1], cell[0] - 2, cell[1] - 1, current_l, 'UL') can_move = 1 if cell[1] < n - 1 and board[cell[0] - 2][cell[1] + 1] < 0: update_table(board, path, new_cells, cell[0], cell[1], cell[0] - 2, cell[1] + 1, current_l, 'UR') can_move = 1 if cell[1] < n - 2 and board[cell[0]][cell[1] + 2] < 0: update_table(board, path, new_cells, cell[0], cell[1], cell[0], cell[1] + 2, current_l, 'R') can_move = 1 if cell[0] < n - 2: if cell[1] < n - 1 and board[cell[0] + 2][cell[1] + 1] < 0: update_table(board, path, new_cells, cell[0], cell[1], cell[0] + 2, cell[1] + 1, current_l, 'LR') can_move = 1 if cell[1] > 0 and board[cell[0] + 2][cell[1] - 1] < 0: update_table(board, path, new_cells, cell[0], cell[1], cell[0] + 2, cell[1] - 1, current_l, 'LL') can_move = 1 if cell[1] > 1 and board[cell[0]][cell[1] - 2] < 0: update_table(board, path, new_cells, cell[0], cell[1], cell[0], cell[1] - 2, current_l, 'L') can_move = 1 current_cells = new_cells if board[i_end][j_end] == -1: print('Impossible') else: print(board[i_end][j_end]) print(' '.join(path[(i_end, j_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)