#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #include using std::cerr; using std::cin; using std::cout; using std::abs; using std::min; using std::max; using std::swap; using std::map; using std::pair; using std::set; using std::string; using std::vector; using ll = long long; using uint = unsigned int; using pii = pair; using pll = pair; #define ff first #define ss second #define pb emplace_back template void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h <<"\n"; } template void _dbg(const char* _s, T _h, Ts... _t) { int _b = 0; while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',') cerr << *_s++; cerr << " = " << _h << ","; _dbg(_s+1, _t...); } #ifdef LOCAL #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__) #else #define dbg(...) #endif struct init { init() { cin.tie(0); std::iostream::sync_with_stdio(0); cout << std::fixed << std::setprecision(10); cerr << std::fixed << std::setprecision(5); #ifdef LOCAL srand(300); #else using namespace std::chrono; srand(duration_cast(high_resolution_clock::now().time_since_epoch()).count()); #endif } ~init() { #ifdef LOCAL cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n"; #endif } } init; const int D = 6, MAXN = 228, INF = 1e9; int d[MAXN][MAXN]; int f[MAXN][MAXN]; const int dx[] = {-2, -2, 0, +2, +2, 0}; const int dy[] = {-1, +1, +2, +1, -1, -2}; const string ds[] = {"UL", "UR", "R", "LR", "LL", "L"}; int n; bool ok(int x, int y) { return 0 <= x && x < n && 0 <= y && y < n; } pii q[MAXN * MAXN]; int main() { cin >> n; for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) d[i][j] = INF; int sx, sy, fx, fy, l = 0, r = 0; cin >> sx >> sy >> fx >> fy; d[sx][sy] = 0; q[r++] = {sx, sy}; while (l < r) { pii v = q[l++]; int x = v.ff, y = v.ss; for (int i = 0; i < D; ++i) { int tox = x + dx[i], toy = y + dy[i]; if (ok(tox, toy)) { if (d[tox][toy] > d[x][y] + 1) { d[tox][toy] = d[x][y] + 1; f[tox][toy] = i; q[r++] = {tox, toy}; } } } } if (d[fx][fy] == INF) { cout << "Impossible\n"; return 0; } vector ans; while (sx != fx || sy != fy) { int i = f[fx][fy]; ans.pb(ds[i]); i = (i + 3) % 6; fx += dx[i]; fy += dy[i]; } reverse(ans.begin(), ans.end()); cout << ans.size() << '\n'; for (auto i : ans) cout << i << ' '; cout << '\n'; return 0; }