#include using namespace std; #define inrep int t; cin >> t; for(int tc=1; tc<=t; tc++) #define pb push_back #define fi first #define sc second bool visb[207][207] = {0}; vector > curPath; stack > st; string grid[207]; vector > v[200+7][200+7]; void findpath(int x, int y) { if (visb[x][y]) return ; visb[x][y] = 1; if (grid[x][y] == 'S') { for(auto i : curPath) { st.push({i.fi, i.sc}); } return ; } for(auto i : v[x][y]) { curPath.pb(i); findpath(i.fi, i.sc); } } int main() { int n; cin >> n; int is, js, ie, je; cin >> is >> js >> ie >> je; grid[is][js] = 'S'; grid[ie][je] = 'E'; queue > > q; q.push({0, {is, js}}); int iter = 0; bool vis[207][207] = {0}; while(q.size()) { iter++; if (iter == (int) 1e8) break; int x = q.front().second.first, y = q.front().second.second, cost = q.front().first; q.pop(); if (vis[x][y]) continue; vis[x][y] = 1; if (x == ie && y == je) { cout << cost << "\n"; // cout << "NOT IMPOSSIBLE" << "\n"; goto dia; } if (x - 2 >= 0 && y - 1 >= 0) { v[x-2][y-1].pb({x, y}); q.push({cost+1,{x-2, y-1}}); } if (x - 2 >= 0 && y + 1 < n) { v[x-2][y+1].pb({x, y}); q.push({cost+1, {x-2, y+1}}); } if (y + 2 < n) { v[x][y+2].pb({x, y}); q.push({cost+1, {x, y+2}}); } if (x + 2 < n && y + 1 < n) { v[x+2][y+1].pb({x, y}); q.push({cost+1, {x+2, y+1}}); } if (x + 2 < n && y - 1 >= 0) { v[x+2][y-1].pb({x, y}); q.push({cost+1, {x+2, y-1}}); } if (y - 2 >= 0) { v[x][y-2].pb({x, y}); q.push({cost+1, {x, y-2}}); } } cout << "Impossible" << "\n"; return 0; dia:; st.push({ie, je}); findpath(ie, je); int nowx = st.top().fi, nowy = st.top().sc; st.pop(); while(st.size()) { int x = st.top().fi, y = st.top().sc; st.pop(); nowx -= x, nowy -= y; if (nowx == 2 && nowy == 1) { cout << "UL"; } else if (nowx == 2 && nowy == -1) { cout << "UR"; } else if (nowx == 0 && nowy == -2) { cout << "R"; } else if (nowx == -2 && nowy == -1) { cout << "LR"; } else if (nowx == -2 && nowy == 1) { cout << "LL"; } else if (nowx == 0 && nowy == 2) { cout << "L"; } nowx = x, nowy = y; if (st.size() == 0) { cout << "\n"; } else cout << " "; } }