#include #include using namespace std; #define ii pair #define iii pair int gox[6] = {-2, -2, 0, 2, 2, 0}, goy[6] = {-1, 1, 2, 1, -1, -2}; string dir[6] = {"UL", "UR", "R", "LR", "LL", "L"}; int n, x1, y1, x2, y2; bool vis[210][210]; ii trace[210][210]; void Trace(int x, int y) { if (x == x1 && y == y1) return; Trace(trace[x][y].first, trace[x][y].second); for (int i = 0; i < 6; i++) if (x - gox[i] == trace[x][y].first && y - goy[i] == trace[x][y].second) { cout << dir[i] << ' '; return; } } int main() { cin >> n >> x1 >> y1 >> x2 >> y2; queue bfs; bfs.push(iii(0, ii(x1, y1))); while (!bfs.empty()) { int k = bfs.front().first, x = bfs.front().second.first, y = bfs.front().second.second; bfs.pop(); if (x == x2 && y == y2) { cout << k << '\n'; Trace(x, y); return 0; } for (int i = 0; i < 6; i++) { int u = x + gox[i], v = y + goy[i]; if (0 <= u && u < n && 0 <= v && v < n && !vis[u][v]) vis[u][v] = true, trace[u][v] = ii(x, y), bfs.push(iii(k + 1, ii(u, v))); } } cout << "Impossible"; }