#include #include #include using namespace std; #include void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { // Print the distance along with the sequence of moves. queue Q; int i, j, count = 0; while((i_start != i_end || j_start != j_end)) { count++; if(j_start < n - 1 && j_end >= j_start) { if(i_start > i_end) { if(j_start == j_end && j_start > 0) { Q.push("UL"); i_start -= 2; j_start--; } else { Q.push("UR"); i_start -= 2; j_start ++; } } else if(j_start + 2 < n && ( (2 * (j_end - j_start)) > i_end - i_start )) { Q.push("R"); j_start += 2; } else { Q.push("LR"); j_start++; i_start += 2; } } else { if(i_end < i_start) { Q.push("UL"); j_start--; i_start -= 2; } else if(i_end > i_start) { Q.push("LL"); j_start--; i_start += 2; } else { Q.push("L"); j_start -= 2; } } } cout << count << '\n'; while(!Q.empty()) { cout << Q.front() << ' '; Q.pop(); } } 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; if(i_start % 2 != i_end % 2 || j_end % 2 != (j_start + (abs(i_start - i_end) / 2)) % 2) cout << "Impossible\n"; else printShortestPath(n, i_start, j_start, i_end, j_end); return 0; }