#include using namespace std; bool visited[201][201]; class knight { public: int score, x, y; string path; knight() { score = 0; path = ""; } }; void bfs(int p, int q, int x, int y, int n) { queue q1; knight k1; k1.x = p; k1.y = q; visited[p][q] = true; q1.push(k1); while (!q1.empty()) { knight temp = q1.front(); q1.pop(); if ((temp.x == x) && (temp.y == y)) { printf("%d\n", temp.score); cout << temp.path << endl; return; } int i = temp.x; int j = temp.y; knight k2; k2 = temp; //UL if ((i - 2 >= 0) && (j - 1 >= 0) && (!visited[i - 2][j - 1])) { k2.score = temp.score + 1; k2.path = temp.path + "UL "; k2.x = i - 2; k2.y = j - 1; visited[i - 2][j - 1]=true; q1.push(k2); } //UR if ((i - 2 >= 0) && (j + 1 < n) && (!visited[i - 2][j + 1])) { k2.score = temp.score + 1; k2.path = temp.path + "UR "; k2.x = i - 2; k2.y = j + 1; visited[i - 2][j + 1]=true; q1.push(k2); } //R if ((j + 2 < n) && (!visited[i][j + 2])) { k2.score = temp.score + 1; k2.path = temp.path + "R "; k2.x = i; k2.y = j + 2; visited[i][j + 2]=true; q1.push(k2); } //LR if ((i + 2 < n) && (j + 1 < n) && (!visited[i + 2][j + 1])) { k2.score = temp.score + 1; k2.path = temp.path + "LR "; k2.x = i + 2; k2.y = j + 1; visited[i + 2][j + 1]=true; q1.push(k2); } //LL if ((i + 2 < n) && (j - 1 >= 0) && (!visited[i + 2][j - 1])) { k2.score = temp.score + 1; k2.path = temp.path + "LL "; k2.x = i + 2; k2.y = j - 1; visited[i + 2][j - 1]=true; q1.push(k2); } //L if ((j - 2 >= 0) && (!visited[i][j - 2])) { k2.score = temp.score + 1; k2.path = temp.path + "L "; k2.x = i; k2.y = j - 2; visited[i][j - 2]=true; q1.push(k2); } } printf("Impossible\n"); } int main() { int n, p, q, x, y; scanf("%d", &n); scanf("%d %d %d %d", &p, &q, &x, &y); bfs(p, q, x, y, n); return 0; }