#include using namespace std; bool inside(int n, int x, int y) { return x>=0 && x=0 && y> a(n, vector(n, -1)); int dx[6] = {-2, -2, 0, 2, 2, 0}; int dy[6] = {-1, 1, 2, 1, -1, -2}; string cmd[6] = {"UL", "UR", "R", "LR", "LL", "L"}; queue q; q.push(i_end); q.push(j_end); a[i_end][j_end] = 0; while (!q.empty()) { int i = q.front(); q.pop(); int j = q.front(); q.pop(); for (int d = 0; d < 6; d++) { if (inside(n, i-dx[d], j-dy[d]) && a[i-dx[d]][j-dy[d]] == -1) { a[i-dx[d]][j-dy[d]] = a[i][j] + 1; q.push(i-dx[d]); q.push(j-dy[d]); } } } if (a[i_start][j_start] == -1) { cout << "Impossible" << endl; return; } int i = i_start, j = j_start; cout << a[i][j] << endl; while (i != i_end || j != j_end) { for (int d = 0; d < 6; d++) { int ni = i+dx[d], nj = j+dy[d]; if (inside(n, ni, nj) && a[ni][nj] == a[i][j] - 1) { cout << cmd[d] << (a[ni][nj] == 0? "\n":" "); i = ni; j = nj; break; } } } } int main() { int n; cin >> n; int i_start; int j_start; int i_end; int j_end; cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(n, i_start, j_start, i_end, j_end); return 0; }