#include using namespace std; void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { static std::vector names = {"UL","UR","R","LR","LL","L"}; static std::vector> directions = {{-2, -1}, {-2, +1}, {0, +2}, {+2, +1}, {+2, -1}, {0, -2}}; std::unordered_set traversed; std::queue, std::vector>> parents; parents.emplace(std::make_pair(i_start, j_start), std::vector()); while(!parents.empty()) { auto parent = parents.front(); parents.pop(); if(parent.first.first >= n || parent.first.first < 0 || parent.first.second >= n || parent.first.second < 0 || traversed.count(parent.first.first*n+parent.first.second)>0 ) continue; if(parent.first.first==i_end && parent.first.second==j_end) { std::cout << parent.second.size() << std::endl; for(const auto& el : parent.second) std::cout << names[el] << " "; std::cout << std::endl; return; } traversed.insert(parent.first.first*n+parent.first.second); for(int i=0; i < directions.size(); ++i) { auto elem = directions[i]; elem.first+=parent.first.first; elem.second+=parent.first.second; if(elem.first >= n || elem.first < 0 || elem.second >= n || elem.second < 0 || traversed.count(elem.first*n+elem.second)>0 ) continue; parent.second.push_back(i); parents.emplace(std::make_pair(elem.first, elem.second), parent.second); parent.second.pop_back(); } } std::cout << "Impossible" << std::endl; } int main() { int n; cin >> n; int i_start; int j_start; int i_end; int j_end; cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(n, i_start, j_start, i_end, j_end); return 0; }