#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define F first #define S second #define pb push_back #define epr(...) fprintf(stderr, __VA_ARGS__) #define db(x) cerr << #x << " = " << x << endl #define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; #define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n" #define dbv(a) cerr << #a << ": "; for (auto& xxxx: a) cerr << xxxx << " "; cerr << endl; #define forn(i, n) for (int i = 0; i < (int)(n); i++) #define all(a) (a).begin(), (a).end() #define sz(a) (int)a.size() #define pw(n) (1ll << (n)) #define equal equalll #define less lesss typedef double dbl; typedef long long ll; const int N = 1000; const int INF = 1.01e9; typedef vector vi; const int dx[6] = {-2, -2, 0, 2, 2, 0}; const int dy[6] = {-1, 1, 2, 1, -1, -2}; const string name[6] = {"UL", "UR", "R", "LR", "LL", "L"}; //UL, UR, R, LR, LL, L. int type[N][N]; pair par[N][N]; int main() { #ifdef HOME assert(freopen("in", "r", stdin)); #endif int n; int x1, y1, x2, y2; cin >> n >> x1 >> y1 >> x2 >> y2; vector> dist(n, vector(n, INF)); dist[x1][y1] = 0; queue> q; q.push({x1, y1}); while (!q.empty()) { int x = q.front().F; int y = q.front().S; //db2(x, y); q.pop(); for (int i = 0; i < 6; i++) { int xx = x + dx[i]; int yy = y + dy[i]; if (0 <= xx && xx < n && 0 <= yy && yy < n && dist[xx][yy] > dist[x][y] + 1) { dist[xx][yy] = dist[x][y] + 1; par[xx][yy] = {x, y}; type[xx][yy] = i; q.push({xx, yy}); } } } if (dist[x2][y2] == INF) { puts("Impossible"); } else { vector res; while (dist[x2][y2] != 0) { res.pb(name[type[x2][y2]]); int xx = par[x2][y2].F; int yy = par[x2][y2].S; x2 = xx; y2 = yy; } reverse(all(res)); cout << res.size() << endl; for (auto s: res) { cout << s << " "; } cout << endl; } #ifdef HOME epr("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC)); #endif return 0; }