#include #include #include #include #include #include #include #include #include using namespace std; pair, bool> printm(int n, int is, int js, int ie, int je) { static int dr[] = {-2, -2, 0, 2, 2, 0}; static int dc[] = { -1, 1, 2, 1, -1, -2}; static char const *nm[] = {"UL", "UR", "R", "LR", "LL", "L"}; vector r; vector vis(n*n, -2); deque> Q; Q.emplace_back(is, js, -1); bool found = false; while (!Q.empty()) { int i, j, d; tie(i, j, d) = Q.front(); Q.pop_front(); if (vis[i*n + j] >= -1) continue; vis[i*n + j] = d; if (i == ie && j == je){ found = true; break; } for (d = 0; d < 6; ++d){ int ni = i + dr[d], nj = j + dc[d]; if (ni >= 0 && nj >= 0 && ni < n && nj < n) Q.emplace_back(ni, nj, d); } } if (found){ while (vis[ie*n + je] >= 0){ int d = vis[ie*n + je]; ie -= dr[d]; je -= dc[d]; r.push_back(nm[d]); } reverse(r.begin(), r.end()); return make_pair(r, true); } else return make_pair(r, false); } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n, is, js, ie, je; cin >> n >> is >> js >> ie >> je; auto r = printm(n, is, js, ie, je); if (r.second){ cout << r.first.size() << '\n'; for (int i = 0; i < r.first.size(); ++i){ if (i > 0) cout << ' '; cout << r.first[i]; } cout << '\n'; } else { cout << "Impossible\n"; } return 0; }