#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include using namespace std; const int INF = (int)1e9; const vector> shifts = {{-2,-1}, {-2,+1}, {0,+2}, {+2,+1}, {+2,-1}, {0,-2}}; const string e[6] = {"UL","UR","R","LR","LL","L"}; vector> neighbors(int n, int i) { int x = i/n, y = i%n; vector> ret; for (int i = 0; i < 6; i++) { auto sh = shifts[i]; int nx = x+sh.first, ny = y+sh.second; if (0 <= nx && nx < n && 0 <= ny && ny < n) ret.emplace_back(n*nx+ny,e[i]); } return ret; } int main(int argc, char** argv) { ios_base::sync_with_stdio(0); cin.tie(0); int n, sx, sy, fx, fy; cin >> n >> sx >> sy >> fx >> fy; vector dist(n*n, INF); vector> pr(n*n, {-1,""}); int st = n*sx+sy; dist[st] = 0; vector q = {st}; for (int i = 0; i < q.size(); i++) { auto go = neighbors(n, q[i]); for (auto j: go) if (dist[q[i]]+1 < dist[j.first]) { dist[j.first] = dist[q[i]]+1; pr[j.first] = {q[i],j.second}; q.push_back(j.first); } } int c = n*fx+fy; if (dist[c] == INF) { cout << "Impossible\n"; return 0; } vector ans; for (;;) { if (c == st) break; ans.emplace_back(pr[c].second); c = pr[c].first; } reverse(ans.begin(), ans.end()); cout << ans.size() << "\n"; for (auto step: ans) cout << step << " "; cout << "\n"; return 0; }