#include #include #include #include "string.h" #include #include using namespace std; //UL, UR, R, LR, LL, L int dx[] = {-2,-2,0,2,2,0}; int dy[] = {-1,1,2,1,-1,-2}; string go[] = {"UL","UR","R","LR","LL","L"}; pairq[205*205]; int n; int par[205][205]; bool ok(int x, int y){ if(x >= n || y >= n || x < 0 || y < 0 || ~par[x][y])return 0; return 1; } vector bfs(int sx, int sy, int tx, int ty){ int h, t; h = t = 0; memset(par, -1, sizeof par); q[t++] = make_pair(sx,sy); par[sx][sy] = 6; while(h < t){ auto cur = q[h++]; for(int i = 0; i < 6; i++){ int nx = cur.first + dx[i]; int ny = cur.second + dy[i]; if(!ok(nx,ny))continue; q[t++] = {nx,ny}; par[nx][ny] = i; } } if(par[tx][ty] == -1)return {"Impossible"}; vectorret; paircur = {tx,ty}; while(true){ int x = par[cur.first][cur.second]; if(x == 6)break; ret.push_back(go[x]); cur.first -= dx[x]; cur.second -= dy[x]; } reverse(ret.begin(),ret.end()); return ret; } int main() { cin >> n; int sx,sy,dx,dy; cin >> sx >> sy >> dx >> dy; auto cur = bfs(sx,sy,dx,dy); if(cur.size() && cur[0][0] == 'I'){ cout << cur[0] << '\n'; return 0; } cout << cur.size() << '\n'; for(int i = 0; i < cur.size(); i++) cout << cur[i] << " \n"[i+1==cur.size()]; return 0; }