#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. if (i_start % 2 != i_end % 2){ cout << "Impossible" << endl; return; } int i_dif = abs(i_start - i_end); if (j_start % 2 == j_end % 2){ if (!(abs(i_start - i_end) % 4 == 0)){ cout << "Impossible" << endl; } } else { if (abs(i_start - i_end) % 4 == 0){ cout << "Impossible" << endl; } } int n1 = 0; int i = i_start ; int j = j_start; vector moves; while (i != i_end || j != j_end){ if (i_end - i < 0 && j_end - j <= 0 && i > 0){ moves.push_back("UL"); n1++; i -= 2; j-=1; continue; } if (i_end - i < 0 && j_end - j >= 0 && i < n){ moves.push_back("UR"); n1++; i -= 2; j+=1; continue; } if (i_end - i == 0 && j_end - j > 0){ moves.push_back("R"); n1++; j +=2; continue; } if (i_end - i > 0 && j_end - j >= 0 && i < n){ moves.push_back("LR"); n1++; i += 2; j+=1; continue; } if (i_end - i > 0 && j_end - j <= 0 && i > 0){ moves.push_back("LL"); n1++; i += 2; j-=1; continue; } if (i_end - i == 0 && j_end - j < 0){ moves.push_back("L"); n1++; j -=2; continue; } } cout << n1 << endl; for (auto i : moves){ cout << i << " "; } } 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; }