#include using namespace std; vector> keep; void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { if(abs(i_start-i_end)%2 == 1){ cout << "Impossible" << endl; keep.clear(); return; } if(j_start == j_end && abs(i_start-i_end)%4 != 0){ cout << "Impossible" << endl; keep.clear(); return; } if(i_start>=n || j_start>=n){ cout << "Impossible" << endl; keep.clear(); return; } if(i_start+1 == i_end && j_start-1 == j_end){ cout << "Impossible" << endl; keep.clear(); return; } if(i_start+1 == i_end && j_start == j_end){ cout << "Impossible" << endl; keep.clear(); return; } if(i_start+1 == i_end && j_start+1 == j_end){ cout << "Impossible" << endl; keep.clear(); return; } if(i_start == i_end && j_start+1 == j_end){ cout << "Impossible" << endl; keep.clear(); return; } if(i_start == i_end && j_start-1 == j_end){ cout << "Impossible" << endl; keep.clear(); return; } if(i_start-1 == i_end && j_start-1 == j_end){ cout << "Impossible" << endl; keep.clear(); return; } if(i_start-1 == i_end && j_start == j_end){ cout << "Impossible" << endl; keep.clear(); return; } if(i_start-1 == i_end && j_start+1 == j_end){ cout << "Impossible" << endl; keep.clear(); return; } if(i_start == i_end && j_start == j_end){ return; } if(i_start > i_end && j_start >= j_end){ pair p1 = {"UL", 1}; keep.push_back(p1); printShortestPath(n, i_start-2, j_start-1, i_end, j_end); }else if(i_start > i_end && j_start < j_end){ pair p1 = {"UR", 2}; keep.push_back(p1); printShortestPath(n, i_start-2, j_start+1, i_end, j_end); }else if(i_start == i_end && j_start < j_end){ pair p1 = {"R", 3}; keep.push_back(p1); printShortestPath(n, i_start, j_start+2, i_end, j_end); }else if(i_start < i_end && j_start <= j_end){ pair p1 = {"LR", 4}; keep.push_back(p1); printShortestPath(n, i_start+2, j_start+1, i_end, j_end); }else if(i_start < i_end && j_start > j_end){ pair p1 = {"LL", 5}; keep.push_back(p1); printShortestPath(n, i_start+2, j_start-1, i_end, j_end); }else if(i_start == i_end && j_start > j_end){ pair p1 = {"L", 6}; keep.push_back(p1); printShortestPath(n, i_start, j_start-2, i_end, j_end); } } 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); if(keep.size() != 0){ cout << keep.size() << endl; for(int i = 0;i keep[j].second){ pair p1 = keep[j]; keep[j] = keep[i]; keep[i] = p1; } } } for(int i = 0;i