#include using namespace std; struct node{ string s; int x; int y; node* last; node(string s, int x, int y, node* last){ this->s = s; this->x = x; this->y = y; this->last = last; } }; 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. queue que; node* start = new node("", i_start, j_start, nullptr); int ds[6][2] = {{-2, -1}, {-2, 1}, {0, 2}, {2, 1}, {2, -1}, {0, -2}}; string dstr[6] = {"UL", "UR", "R", "LR", "LL", "L"}; vector> visited(n, vector(n, false)); int level = 1; que.push(start); visited[i_start][j_start] = true; while(!que.empty()){ int size = que.size(); for(int i = 0; i < size; i++){ auto cur = que.front(); que.pop(); for(int i = 0; i < 6; i++){ int x = cur->x + ds[i][0]; int y = cur->y + ds[i][1]; if(x >= 0 && x < n && y >= 0 && y < n && !visited[x][y]){ if(x == i_end && y == j_end){ stack stk; cout << level << endl; stk.push(dstr[i]); while(cur->last){ stk.push(cur->s); cur = cur->last; } while(stk.size() > 1){ cout << stk.top() << " "; stk.pop(); } cout << stk.top(); return; } visited[x][y] = true; node* new_node = new node(dstr[i], x, y, cur); que.push(new_node); } } } level++; } cout << "Impossible" << 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; }