#include #include #include #include #include #include #include #include #include using namespace std; vector GetMinimal(int rows, int istart, int jstart, int iend, int jend) { queue> q; int row[] = {-2,-2,0,2, 2,0}; int col[] = {-1, 1,2,1,-1,-2}; string sms[] = {"UL","UR","R","LR","LL","L"}; set>s; map,pair> m; map, string> sm; q.push(std::make_pair(istart,jstart)); s.insert(std::make_pair(istart,jstart)); bool found = false; while(not q.empty()){ auto x = q.front(); q.pop(); for(int i=0; i<6 && not found;i++){ int newrow = x.first + row[i]; if(newrow < 0 || newrow >= rows) continue; int newcol = x.second + col[i]; if(newcol <0 || newcol >= rows ) continue; auto pr = std::make_pair(newrow, newcol); if(s.find(pr) == s.end()){ m[pr] = x; //cout< ss; if(not found) return ss; auto pr = std::make_pair(iend, jend); auto st = std::make_pair(istart, jstart); while(pr != st){ string str = sm[pr]; ss.push_back(str); pr = m[pr]; } reverse(ss.begin(),ss.end()); return ss; } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int rows; cin >> rows; int istart, jstart, iend, jend; cin >> istart; cin >> jstart; cin >> iend; cin >> jend; vector steps = GetMinimal(rows, istart, jstart, iend, jend); if(steps.size() == 0) cout<<"Impossible"<