#include using namespace std; vector < vector < int > > cost(250, vector < int > (250, 2e9)); vector < string > sol; vector < string > cur_sol; vector < int > di = {-2, -2, 0, 2, 2, 0}; vector < int > dj = {-1, 1, 2, 1, -1, -2}; vector < string > v = {"UL", "UR", "R", "LR", "LL", "L"}; int get_dist(pair < int, int > a, pair < int, int > b) { return abs(a.first - b.first) + abs(a.second - b.second); } bool is_good(pair < int, int > a, int n) { return a.first >= 0 and a.second >= 0 and a.first < n and a.second < n; } void Backt(int cur, int n, pair < int, int > cur_poz, pair < int, int > fin, int &ans) { if (cur_poz == fin) { if (ans > cur) { ans = cur; sol = cur_sol; } return; } if (cost[cur_poz.first][cur_poz.second] <= cur) { return; } cost[cur_poz.first][cur_poz.second] = cur; for (int i = 0; i < 6; i ++) { pair < int, int > ne = cur_poz; ne.first += di[i]; ne.second += dj[i]; if (not is_good(ne, n)) { continue; } if (get_dist(cur_poz, fin) < get_dist(ne, fin)) { continue; } cur_sol.push_back(v[i]); Backt(cur + 1, n, ne, fin, ans); cur_sol.pop_back(); } } int main() { ios::sync_with_stdio(false); int n; cin >> n; pair < int, int > start, fin; cin >> start.first >> start.second >> fin.first >> fin.second; int i = abs(start.first - fin.first); int j = abs(start.second - fin.second); if ((i % 4) and (j % 2 == 0)) { cout << "Impossible\n"; return 0; } else if ((i % 4 == 0) and (j % 2)) { cout << "Impossible\n"; return 0; } else if (i % 2) { cout << "Impossible\n"; return 0; } int ans = 1e9; Backt(1, n, start, fin, ans); cout << ans - 1 << '\n'; for (auto x : sol) { cout << x << ' '; } }