#include #include #include #include using namespace std; const int NUM_MOVES = 6; const string MOVES[NUM_MOVES] = {"UL", "UR", "R", "LR", "LL", "L"}; const int DELTA[NUM_MOVES][2] = {{-2, -1}, {-2, 1}, {0, 2}, {2, 1}, {2, -1}, {0, -2}}; const int MAX_N = 500; const int NUM_BIT = 32; int vis[MAX_N][MAX_N / NUM_BIT + 1]; int start[2], tar[2]; int n; struct coord { int i, j, l; string moves; coord(int i, int j, int l, string moves) { this->i = i; this->j = j; this->l = l; this->moves = moves; } }; void BFS() { queue q; q.push(coord(start[0], start[1], 0, "")); vis[q.front().i][q.front().j / NUM_BIT] = vis[q.front().i][q.front().j / NUM_BIT] | 1 << q.front().j % NUM_BIT; while(!q.empty()){ for(int i = 0; i < NUM_MOVES; i++){ coord nxt = coord(q.front().i + DELTA[i][0], q.front().j + DELTA[i][1], q.front().l + 1, q.front().moves + (q.front().l ? " " : "") + MOVES[i]); if(nxt.i < 0 || nxt.j < 0 || nxt.i >= n || nxt.j >= n) continue; if(!(vis[nxt.i][nxt.j / NUM_BIT] & 1 << nxt.j % NUM_BIT)){ vis[nxt.i][nxt.j / NUM_BIT] = vis[nxt.i][nxt.j / NUM_BIT] | 1 << nxt.j % NUM_BIT; q.push(nxt); } if(nxt.i == tar[0] && nxt.j == tar[1]){ cout << nxt.l << endl; cout << nxt.moves << endl; return; } } q.pop(); } cout << "Impossible" << endl; } int main() { cin >> n >> start[0] >> start[1] >> tar[0] >> tar[1]; BFS(); return 0; }