#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. int i_cur = i_start, j_cur = j_start; int length = 0; int counts[6] = {0, 0, 0, 0, 0, 0}; while (i_cur != i_end || j_cur != j_end) { if (abs(i_cur-i_end) <= 1 && abs(j_cur-j_end) <= 1) { cout << "Impossible" << endl; return; } ++length; if (i_end < i_cur && j_end <= j_cur) { ++counts[0]; i_cur -= 2; j_cur -= 1; continue; } if (i_end < i_cur) { ++counts[1]; i_cur -= 2; j_cur += 1; continue; } if (i_end > i_cur && j_end >= j_cur) { ++counts[3]; i_cur += 2; j_cur += 1; continue; } if (i_end > i_cur) { ++counts[4]; i_cur += 2; j_cur -= 1; continue; } if (j_cur > j_end) { ++counts[5]; j_cur -= 2; } else { ++counts[2]; j_cur += 2; } } cout << length << endl; for (int i = 0; i < counts[0]; ++i) cout << "UL "; for (int i = 0; i < counts[1]; ++i) cout << "UR "; for (int i = 0; i < counts[2]; ++i) cout << "R "; for (int i = 0; i < counts[3]; ++i) cout << "LR "; for (int i = 0; i < counts[4]; ++i) cout << "LL "; for (int i = 0; i < counts[5]; ++i) cout << "L "; } 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; }