#include using namespace std; int n, start_x, start_y, end_x, end_y, minMoves = INT_MAX; vector> moves; vector v; bool vis[205][205], foundWay; void f(int x, int y, int numOfMoves) { vis[x][y] = true; if(x == end_x and y == end_y) { moves.push_back(v); minMoves = min(minMoves, numOfMoves); foundWay = true; vis[x][y] = false; v.pop_back(); return; } if(numOfMoves >= minMoves) { if(!v.empty()) v.pop_back(); vis[x][y] = false; numOfMoves -= 1; return; } // Check UL if(x - 2 >= 0 and y - 1 >= 0 and !vis[x - 2][y - 1]) { v.push_back("UL"); f(x - 2, y - 1, numOfMoves + 1); } // Check UR if(x - 2 >= 0 and y + 1 <= n - 1 and !vis[x - 2][y + 1]) { v.push_back("UR"); f(x - 2, y + 1, numOfMoves + 1); } // Check R if(y + 2 <= n - 1 and !vis[x][y + 2]) { v.push_back("R"); f(x, y + 2, numOfMoves + 1); } // Check LR if(x + 2 <= n - 1 and y + 1 <= n - 1 and !vis[x + 2][y + 1]) { v.push_back("LR"); f(x + 2, y + 1, numOfMoves + 1); } // Check LL if(x + 2 <= n - 1 and y - 1 >= 0 and !vis[x + 2][y - 1]) { v.push_back("LL"); f(x + 2, y - 1, numOfMoves + 1); } // Check L if(y - 2 >= 0 and !vis[x][y - 2]) { v.push_back("L"); f(x, y - 2, numOfMoves + 1); } if(!v.empty()) v.pop_back(); vis[x][y] = false; numOfMoves -= 1; } int main() { cin >> n >> start_x >> start_y >> end_x >> end_y; f(start_x, start_y, 0); if(!foundWay) { cout << "Impossible" << endl; return 0; } // order of priority: UL, UR, R, LR, LL, L for(int i = 0; i < moves.size(); i++) { if(moves[i].size() == minMoves) { cout << minMoves << endl; for(int j = 0; j < moves[i].size(); j++) cout << moves[i][j] << " "; break; } } return 0; }