#include using namespace std; #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define PB push_back #define INF 2147483647 #define MP make_pair #define PII pair #define VS vector #define VI vector #define S size() #ifdef _SOUL_LOCAL #define print(___v) {cout<<"L:"<<__LINE__<<" [";if(___v.S)cout<<___v[0];FOR(___i,1,___v.S)cout<<","<<___v[___i];cout<<"]\n";} #define DEBUG(___x) cout<<"L:"<<__LINE__<<" "<<#___x<<" = ["<<___x<<"]"< string tos( T a ) { stringstream ss; string ret; ss << a; ss >> ret; return ret;} int N, D[207][207], vis[207][207]; struct mv { int x; int y; string st; }; mv P[207][207]; int dx[] = {-2, -2, 0, +2, +2, 0}; int dy[] = {-1, +1, 2, +1, -1, -2}; string dir[] = {"UL", "UR", "R", "LR", "LL", "L"}; int main() { #ifdef _SOUL_LOCAL assert(freopen("in.txt", "r", stdin)); #endif int istart, jstart, iend, jend; while (cin >> N) { cin >> istart >> jstart >> iend >> jend; clr(vis, 0); clr(D, -1); D[istart][jstart] = 0; queue Q; Q.push(MP(istart, jstart)); vis[istart][jstart] = 1; while (!Q.empty()) { PII u = Q.front(); Q.pop(); int d = D[u.first][u.second]; FOR(x,0,6) { int iv = u.first+dx[x]; int jv = u.second+dy[x]; if (iv >= 0 && iv < N && jv >= 0 && jv < N && vis[iv][jv] == 0) { Q.push(MP(iv, jv)); vis[iv][jv] = 1; D[iv][jv] = d+1; mv p; p.x = u.first; p.y = u.second; p.st = dir[x]; P[iv][jv] = p; } } } if (D[iend][jend] == -1) { puts("Impossible"); continue; } cout << D[iend][jend] << endl; VS ans; while (true) { if (istart == iend && jstart == jend)break; mv p = P[iend][jend]; iend = p.x; jend = p.y; ans.PB(p.st); } reverse(ans.begin(), ans.end()); FOR(i,0,ans.S) { if (i > 0)cout << " "; cout << ans[i]; } if (ans.S > 0) cout << endl; } #ifdef _SOUL_LOCAL printf("T+[%.3f] sec\n", (double) clock() / CLOCKS_PER_SEC); #endif return 0; }