#include #include #include using namespace std; 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. int flag = 1, k = 0; string s[200]; while(i_start <= n && j_start <= n && j_start >= 0 && i_start >=0) { // cout << i_start << " " << j_start << endl; if((i_start == i_end && j_start == j_end)) { flag = 0; break; } else if((abs(i_start-i_end) == 1 && (j_start == j_end)) || (abs(j_start-j_end) == 1 && (i_start == i_end) )|| (abs(i_start-j_end) == 1 && abs(i_end-j_start) == 1)) break; if(i_end == i_start && j_end < j_start) { j_start -= 2; s[k++] = "L"; } else if(i_end == i_start && j_end == j_start) { j_start += 2; s[k++] = "R"; } else if(i_end < i_start && j_end < j_start) { i_start -= 2; j_start -= 1; s[k++] = "UL"; } else if(i_end < i_start && j_end >= j_start) { i_start -= 2; j_start += 1; s[k++] = "UR"; } else if(i_end > i_start && j_end < j_start) { i_start += 2; j_start -= 1; s[k++] = "LL"; } else if(i_end > i_start && j_end >= j_start) { i_start += 2; j_start += 1; s[k++] = "LR"; } } if(flag == 1) cout << "Impossible\n"; else { cout << k << endl; for(int i = 0; i < k; i++) cout << s[i] << " "; cout << endl; } } 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; }