#include #define mp make_pair #define ff first #define ss second using namespace std; string s[201][201]; int dp[201][201]; int xs, ys, xe, ye, n; int movex[] = {-2, -2, 0, 2, 2, 0}; int movey[] = {-1, 1, 2, 1, -1, -2}; string moves[] = {"UL", "UR", "R", "LR", "LL", "L"}; bool check(int x, int y) { if(x >= 0 && x < n && y >= 0 && y < n) return 1; return 0; } int main() { int i, j; cin >> n; cin >> xs >> ys >> xe >> ye; queue > > Q; Q.push(mp("", mp(xs, ys))); for(i = 0; i < n; i++) for(j = 0; j < n; j++) dp[i][j] = 1e9; dp[xs][ys] = 0; while(!Q.empty()) { string st = Q.front().ff; int x = Q.front().ss.ff; int y = Q.front().ss.ss; Q.pop(); s[x][y] = st; if(x == xe && y == ye) { cout << dp[x][y] << '\n'; string p[1001]; int m = 0; while(x != xs || y != ys) { m++; p[m] = s[x][y]; for(i = 0; i < 6; i++) if(moves[i] == s[x][y]) { x -= movex[i]; y -= movey[i]; break; } } for(i = m; i >= 1; i--) cout << p[i] << ' '; return 0; } for(i = 0; i < 6; i++){ int xx = x + movex[i]; int yy = y + movey[i]; if(dp[xx][yy] > dp[x][y] + 1 && check(xx, yy)) { dp[xx][yy] = dp[x][y] + 1; Q.push(mp(moves[i], mp(xx, yy))); } } } cout << "Impossible"; return 0; }