#include using namespace std; int distance(int i, int j, int a, int b) { return (i - a) * (i - a) + (j - b) * (j - b); } static int stepcnt = 0; stringstream output; 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. // i - row // j - col if ((i_start & 1) != (i_end & 1)) { stepcnt = -1; cout << "Impossible"; return; } //UL, UR, R, LR, LL, L. int d = distance(i_start, j_start, i_end, j_end); if (d == 0) { return; } int ds[6]; int newi[6] = { i_start - 2, i_start - 2, i_start, i_start + 2, i_start + 2, i_start }; int newj[6] = { j_start - 1, j_start + 1, j_start + 2, j_start + 1, j_start - 1, j_start - 2 }; ds[0] = distance(i_start - 2, j_start - 1, i_end, j_end); ds[1] = distance(i_start - 2, j_start + 1, i_end, j_end); ds[2] = distance(i_start, j_start + 2, i_end, j_end); ds[3] = distance(i_start + 2, j_start + 1, i_end, j_end); ds[4] = distance(i_start + 2, j_start - 1, i_end, j_end); ds[5] = distance(i_start, j_start - 2, i_end, j_end); int min = *min_element(ds, ds + 6); int found = 0; const char *step[] = {"UL", "UR", "R", "LR", "LL", "L"}; for (int i = 0; i < 6; i++) { if (min == ds[i]) { output << step[i] << ' '; found = i; stepcnt++; break; } } if (min == 0) { return; } printShortestPath(n, newi[found], newj[found], 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 (stepcnt != - 1) cout << stepcnt << endl << output.str(); return 0; }