#include #include #include #include #include #include using namespace std; // shortcuts for "common" data types in contests typedef long long ll; typedef pair ii; typedef vector vii; typedef vector vi; #define INF 1000000000 string path[] = {"UL", "UR", "R", "LR", "LL", "L"}; int dx[] = {-1, 1, 2, 1, -1, -2}; int dy[] = {-2, -2, 0, 2, 2, 0}; int n, start; vii p; int ctoi(int r, int c) { return r * n + c; } ii itoc(int idx) { return ii(idx / n, idx % n); } void printPath(int u) { if (u == start) { return; } printPath(p[u].first); cout << path[p[u].second] << " "; } int main() { int sx, sy, ex, ey, end; cin >> n >> sy >> sx >> ey >> ex; start = ctoi(sy, sx); end = ctoi(ey, ex); vi dist(n*n, INF); dist[start] = 0; p.assign(n*n, ii(-1, -1)); queue q; q.push(start); while (!q.empty()) { int u = q.front(); q.pop(); ii coord = itoc(u); for (int d = 0; d < 6; ++d) { int r = coord.first + dy[d]; int c = coord.second + dx[d]; int v = ctoi(r, c); if (r >= 0 && r < n && c >= 0 && c < n && dist[v] == INF) { dist[v] = dist[u] + 1; p[v] = ii(u, d); q.push(v); } } } if (p[end].first == -1) cout << "Impossible" << endl; else { cout << dist[end] << endl; printPath(end); cout << endl; } return 0; }