#include using namespace std; //UL, UR, R, LR, LL, L vector dir[6] = {{-2, -1}, {-2, 1}, {0, 2}, {2, 1}, {2, -1}, {0, -2}}; vector M = {"UL", "UR", "R", "LR", "LL", "L"}; int n; int minMoves = 1e9; vector ans; void Solve(vector path, vector curr, vector dest, set> vis, int moves) { if(moves >= minMoves) { return; } if(curr == dest) { if(moves < minMoves) { minMoves = moves; ans = path; } return; } vis.insert(curr); for(int i=0; i<6; i++) { int y = curr[0] + dir[i][0]; int x = curr[1] + dir[i][1]; if(y < 0 || x < 0 || y >= n || x >= n || vis.count({y, x})) continue; path.push_back(M[i]); Solve(path, {y, x}, dest, vis, moves+1); path.pop_back(); } } int main() { cin >> n; vector S(2), E(2); cin >> S[0] >> S[1] >> E[0] >> E[1]; deque> d = {S}; set> vis = {S}; map, int> dist; map, vector> path; dist[S] = 0; while(!d.empty()) { vector cell = d.front(); d.pop_front(); if(cell == E) { cout << dist[cell] << endl; for(auto it : path[cell]) { cout << it << ' '; } return 0; } for(int i=0; i<6; i++) { vector next = {cell[0] + dir[i][0], cell[1] + dir[i][1]}; if(next[0] < 0 || next[1] < 0 || next[0] >= n || next[1] >= n || vis.count(next)) { continue; } d.push_back(next); vis.insert(next); dist[next] = dist[cell] + 1; path[next] = path[cell]; path[next].push_back(M[i]); } } cout << "Impossible\n"; /* Solve({}, S, E, {}, 0); if(ans.empty()) { cout << "Impossible\n"; return 0; } cout << ans.size() << endl; for(auto it : ans) cout << it << ' '; */ return 0; }