#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MAX 220 int n; int dist[MAX][MAX]; int op[MAX][MAX]; pair pr[MAX][MAX]; int dy[] = { 1,2,1,-1,-2,-1 }; int dx[] = { 2,0,-2,-2,0,2 }; string s[] = { "UR","R","LR","LL","L","UL" }; //UL, UR, R, LR, LL, L map mp; bool cmp(string a,string b){ return mp[a]> n; int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d); for (int i = 0; i < MAX; i++) { for (int j = 0; j < MAX; j++) { dist[i][j] = INT_MAX; } } dist[a][b] = 0; queue > q; q.push(make_pair(a, b)); while (!q.empty()) { int x = q.front().first; int y = q.front().second; q.pop(); for (int i = 0; i < 6; i++) { int xx = x - dx[i]; int yy = y + dy[i]; if (xx >= 0 && yy >= 0 && xx < n&&yy < n) { if (dist[xx][yy] == INT_MAX) { dist[xx][yy] = dist[x][y] + 1; q.push(make_pair(xx, yy)); pr[xx][yy] = make_pair(x, y); op[xx][yy] = i; } } } } if (dist[c][d] == INT_MAX) { puts("Impossible"); return 0; } cout< ans; while (!(a == c&&b == d)) { ans.push_back(s[op[c][d]]); auto it = pr[c][d]; c = it.first; d = it.second; } sort(ans.begin(), ans.end(),cmp); for (int i = 0; i < ans.size(); i++) { if (i)printf(" "); printf("%s", ans[i].c_str()); } puts(""); return 0; }