#include #include #include #include #include #include using namespace std; #define mp make_pair #define X first #define Y second typedef pair II; int n; II operator+ (const II& a, const II& b){ return mp(a.X+b.X,a.Y+b.Y); } II operator- (const II& a, const II& b){ return mp(a.X-b.X,a.Y-b.Y); } const II moves[6] = { {-2,-1}, {-2,1}, {0,2}, {2,1}, {2,-1}, {0,-2} }; const char* names[6] = {"UL", "UR", "R", "LR", "LL", "L"}; bool inBounds(const II& a){ return a.X < n && a.Y < n && a.X >= 0 && a.Y >= 0; } int main() { cin >> n; II start, end; cin >> start.X >> start.Y >> end.X >> end.Y; int* d = new int[n*n]; fill(d, d + n*n, -1); queue q; q.push(start); d[start.X*n + start.Y] = 7; while(q.size()){ II cur = q.front(); if(cur == end){ break; } for(int i = 0; i < 6; i++){ II next = cur + moves[i]; if(!inBounds(next) || d[next.X*n + next.Y] >= 0)continue; d[next.X*n + next.Y] = i; q.push(next); } q.pop(); } if(d[end.X*n + end.Y] < 0){ cout << "Impossible" << endl; }else{ int k = 0; vector path; II cur = end; while(d[cur.X*n+cur.Y] != 7){ path.push_back(d[cur.X*n+cur.Y]); cur = cur - moves[d[cur.X*n+cur.Y]]; } cout << path.size() << endl; for(int i = path.size() - 1; i >= 0; i--){ cout << names[path[i]] << " "; }cout << endl; } delete [] d; return 0; }