/// In The Name Of God #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx") #include #define f first #define s second #define pb push_back #define pp pop_back #define mp make_pair #define sz(x) (int)x.size() #define sqr(x) ((x) * 1ll * (x)) #define all(x) x.begin(), x.end() #define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0); #define nl '\n' #define ioi exit(0); typedef long long ll; typedef long double ld; typedef unsigned long long ull; const int N = (int)5e5 + 7, inf = (int)1e9 + 7, mod = (int)1e9 + 7; const ll linf = (ll)1e18 + 7; const int dx[] = {-1, 1, 2, 1, -1, -2}, dy[] = {-2, -2, 0, 2, 2, 0}; /* UL UR R LL LR L */ using namespace std; #define x1 xxx #define y1 yyy #define x2 xxxxxx #define y2 yyyyyy int n; int x1, y1, x2, y2; int d[555][555], t[555][555]; pair b[555][555]; bool check(int x, int y) { return 1 <= x && x <= n && 1 <= y && y <= n; } int main() { #ifdef IOI2018 freopen ("in.txt", "r", stdin); #endif cin >> n >> x1 >> y1 >> x2 >> y2; x1++, y1++, x2++, y2++; swap(x1, y1); swap(x2, y2); memset(d, -1, sizeof(d)); d[x1][y1] = 0; queue < pair > q; q.push({x1, y1}); string ans[] = {"UL", "UR", "R", "LR", "LL", "L" }; /* L R UL UR LL LR */ while (sz(q)) { pair v = q.front(); q.pop(); for (int i = 0; i <= 5; i++) { int nx = v.f + dx[i], ny = v.s + dy[i]; if (check(nx, ny) && d[nx][ny] == -1) { d[nx][ny] = d[v.f][v.s] + 1; q.push({nx, ny}); b[nx][ny] = v; t[nx][ny] = i; } } } if (d[x2][y2] == -1) cout << "Impossible"; else { cout << d[x2][y2] << nl; vector res; while (1) { if (x2 == x1 && y2 == y1) break; pair nxt = b[x2][y2]; res.pb(ans[t[x2][y2]]); x2 = nxt.f; y2 = nxt.s; } reverse(all(res)); for (auto it : res) { cout << it << ' '; } } ioi }