#include #include #include #include #include using namespace std; enum MOVES { UL = 0, UR, R, LR, LL, L, }; int main() { int N, istart, jstart, iend, jend; std::cin >> N >> istart >> jstart >> iend >> jend; int di = iend - istart; int dj = jend - jstart; // odd vertical jump bool vert_oddness = std::abs(di / 2) % 2; bool horz_oddness = std::abs(dj) % 2; // if we're oddness don't match, it's impossible if (std::abs(di) % 2 || vert_oddness != horz_oddness) { std::cout << "Impossible" << std::endl; } else { std::vector instrs; while (istart != iend || jstart != jend) { MOVES move; if (istart == iend) { if (jend > jstart) { move = R; jstart += 2; } else { move = L; jstart -= 2; } } // move vertically if possible // UL > UR > R > LR > LL > L else if (istart > iend) { // move up istart -= 2; if (jstart < jend) { move = UR; jstart++; } else { move = UL; jstart--; } } // consider moving right before down else { istart += 2; if (jstart <= jend) { move = LR; jstart++; } else { move = LL; jstart--; } } instrs.push_back(move); } // rearrange instrs by priority std::sort(instrs.begin(), instrs.end()); std::cout << instrs.size() << std::endl; for (MOVES instr : instrs) { switch (instr) { case UL: std::cout << "UL "; break; case UR: std::cout << "UR "; break; case R: std::cout << "R "; break; case LR: std::cout << "LR "; break; case LL: std::cout << "LL "; break; case L: std::cout << "L "; } } std::cout << std::endl; } return 0; }