#pragma comment(linker, "/stack:20000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") #include using namespace std; #define fi first #define se second #define endl "\n" #define y1 zyn_Adidas #define ioi exit(0) #define pb push_back #define mp make_pair #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define ub upper_bound #define lb lower_bound #define Zverskii_opt ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef vector vi; typedef pair pii; const int inf = (int)2e9, mod = (int)1e9+7; const ll linf = (ll)2e18; const int maxn = (int)1e5+1; int dx[] = {-2, -2, 0, 2, 2, 0}; int dy[] = {-1, 1 , 2, 1,- 1, -2}; string d_name[] = {"UL", "UR", "R", "LR", "LL", "L"}; int n, x1, y1, x2, y2; map used; int d[201][205]; map p; queue q; bool avaible (int x, int y) { return ((0 <= x && x < n) && (0 <= y && y < n)); } int main () { #ifdef IOI2018 #define fname "" freopen (".in", "r", stdin); freopen (".out", "w", stdout); #endif Zverskii_opt; cin >> n; cin >> x1 >> y1 >> x2 >> y2; queue < pair > q; if (x1 == x2 && y1 == y2) { cout << 0; return 0; } for (int i = 0; i < n; ++ i) for (int j = 0; j < n; ++ j) d[i][j] = inf; d[x1][y1] = 0; q.push (mp (x1, y1)); while (!q.empty ()) { pii cur = q.front (); q.pop (); int x = cur.fi, y = cur.se; used[mp (x, y)] = 1; for (int i = 0; i < 6; ++ i) { if (avaible ((x + dx[i]), (y + dy[i])) && !used[mp ((x + dx[i]), (y + dy[i]))]) { q.push (mp ((x + dx[i]), (y + dy[i]))); used[mp ((x + dx[i]), (y + dy[i]))]=true; if (d[x + dx[i]][y + dy[i]] > d[x][y] + 1) { d[x + dx[i]][y + dy[i]] = d[x][y] + 1; p[mp ((x + dx[i]), (y + dy[i]))] = mp (x, y); } } } } if (!used[mp (x2, y2)]) { cout << "Impossible", ioi; } int x, y; x = x2, y = y2; vector v; while (true) { if (x == x1 && y == y1) break; int X, Y; v.pb (mp (x, y)); X = x, Y = y; x = p[mp (X, Y)].fi; y = p[mp (X, Y)].se; } v.pb (mp (x1, y1)); reverse (all (v)); cout << d[x2][y2] << endl; x = x1, y = y1; for (int i = 0; i < sz (v); ++ i) { pii cur = v[i]; for (int j = 0; j < 6; ++ j) { if (x + dx[j] == cur.fi && y + dy[j] == cur.se) { cout << d_name[j] << ' '; break; } } x = cur.fi, y = cur.se; } ioi; }