#include using namespace std; string Map[] = { "UL", "UR", "R", "LR", "LL", "L" }; 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 = abs(i_start - i_end); int j = abs(j_start - j_end); if(i % 2) { printf("Impossible\n"); return; } else if((((i / 2) % 2) + (j % 2)) == 1) { printf("Impossible\n"); return; } //cout << ((i / 2) + max(0, ((j - (i / 2)) / 2))) << endl; int dx[] = {-2, -2, 0, 2, 2, 0}; int dy[] = {-1, 1, 2, 1, -1, -2}; int x = i_start; int y = j_start; int Count = 0; vector Result; while((x != i_end) || (y != j_end)) { int Min = -1; for(i = 0; i < 6; i++) { if(((x + dx[i]) >= 0) && ((y + dy[i]) >= 0) && ((x + dx[i]) < n) && ((y + dy[i]) < n)) { if(Min == -1) { Min = i; } else if((abs(x + dx[Min] - i_end) + abs(y + dy[Min] - j_end)) > (abs(x + dx[i] - i_end) + abs(y + dy[i] - j_end))) { Min = i; } //cout << i << " " << Min << endl; } } if(Min == -1) { printf("Impossible\n"); return; } x = x + dx[Min]; y = y + dy[Min]; Count++; Result.push_back(Min); //cout << Map[Min] << " "; } cout << Count << endl; sort(Result.begin(), Result.end()); for(i = 0; i < Result.size(); i++) { cout << Map[Result[i]] << " "; } cout << endl; } 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; }