#include using namespace std; void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { // Print the distance along with the sequence of moves. pair knight = make_pair(i_start, j_start); pair end = make_pair(i_end, j_end); vector path; while (knight != end) { if ((knight.first - end.first)%2 != 0) { cout << "Impossible"; break; } if (sqrt(pow(((double)(knight.first-end.first)), 2)+pow(((double)(knight.second-end.second)), 2)) < 2) { cout << "Impossible"; break; } if (end.first < knight.first && end.second <= knight.first) { path.push_back("UL"); knight.first -= 2; knight.second -= 1; } else if (end.first < knight.first && end.second > knight.second) { path.push_back("UR"); knight.first -= 2; knight.second += 1; } else if (end.first == knight.first && end.second > knight.second) { path.push_back("R"); knight.second += 2; } else if (end.first > knight.first && end.second >= knight.second) { path.push_back("LR"); knight.first += 2; knight.second += 1; } else if (end.first > knight.first && end.second < knight.second) { path.push_back("LL"); knight.first += 2; knight.second -= 1; } else if (end.first == knight.first && end.second < knight.second) { path.push_back("L"); knight.second -= 2; } } if (knight == end) { cout << path.size() << endl; for (auto move : path) { cout << move << " "; } cout << 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; }