#include using namespace std; void printShortestPath(int n, int i1, int j1, int i2, int j2) { if(abs(i2-i1)%2==1) { printf("Impossible"); return; } else if(abs(i2-i1)%2==0&&abs(i2-i1)%4!=0&&abs(j2-j1)%2==0) { printf("Impossible"); return; } else if(abs(i2-i1)%2==0&&abs(i2-i1)%4==0&&abs(j2-j1)%2==1) { printf("Impossible"); return; } int arr[6]={-2*n-1,-2*n+1,2,2*n+1,2*n-1,-2}; int visited[n*n] = {0}; int parent[n*n]; // Create a queue for BFS list queue1; visited[i1*n+j1] = 0; queue1.push_back(i1*n+j1); int v=i2*n+j2; parent[i1*n+j1]=-1; string dir[6]={"UL","UR","R","LR","LL","L"}; while(!queue1.empty()) { int s = queue1.front(); queue1.pop_front(); for (int i =0;i<6; i++) { if(arr[i]+s>=0&&arr[i]+s=0;i--){ cout << dir[cnt[i]] << " "; } // Print the distance along with the sequence of moves. } 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; }