#include using namespace std; bool shortestPath (int n, int i_start, int j_start, int i_end, int j_end, vector& s) { //cout << i_start << j_start << endl; if (i_start < 0 || j_start < 0 || i_end >= n || j_end >= n) { return false; } int diffi = i_end - i_start; int diffj = j_end - j_start; if (diffi%2 == 1 || diffi%2 == -1){ return false; } else if (diffi == 0) { if (diffj == 0) { return true; } else if (diffj%2 == 1 || diffj%2 == -1) { return false; } else { int k = diffj/2; if (k > 0) { //cout << "k=" << k << endl; for (int i =0; i < k; i++) { s.push_back("R"); } } else { k = 0 -k; //cout << "0-k=" << k << endl; for (int i =0; i < k; i++) { s.push_back("L"); } } return true; } } //UL, UR, R, LR, LL, L if (diffi > 0) { if (diffj >= 0) { if(shortestPath(n, i_start+2, j_start+1, i_end, j_end, s)) { s.push_back("LR"); return true; } else { return false; } } else { if(shortestPath(n, i_start+2, j_start-1, i_end, j_end, s)) { s.push_back("LL"); return true; } else { return false; } } } else { if (diffj > 0) { if(shortestPath(n, i_start-2, j_start+1, i_end, j_end, s)) { s.push_back("UR"); return true; } else { return false; } } else { if(shortestPath(n, i_start-2, j_start-1, i_end, j_end, s)) { s.push_back("UL"); return true; } else { return false; } } } return false; } 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. vector s; if (shortestPath(n, i_start, j_start, i_end, j_end, s)) { cout << s.size() << endl; for (int i = s.size()-1; i >= 0; i--) { cout << s[i] << " "; } cout << endl; } else { cout << "Impossible" << endl; } return; } 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; }